首页 > 软考
题目内容 (请给出正确答案)
[主观题]

阅读以下说明和Java程序,将应填入(n)处的字句写在对应栏内。 [说明] 下面程序实现十进制向其它

阅读以下说明和Java程序,将应填入(n)处的字句写在对应栏内。

[说明]

下面程序实现十进制向其它进制的转换。

[Java程序]

ClasS Node{

int data;

Node next;

}

class Transform{

private Node top;

public void print(){

Node p;

while(top!=null){

P=top;

if(P.data>9)

System.out.print((char)(P.data+55));

else

System.out.print(p.data);

top=p.next;

}

}

public void Trans(int d,int i){//d为数字;i为进制

int m;

(1) n=false;

Node p;

while(d>0){

(2);

d=d/i;

p=new Node();

if((3) ){

p.data=m;

(4);

top=P;

n=true;

}

else{

p.data=m;

(5);

top=P;

}

}

}

}

查看答案
答案
收藏
如果结果不匹配,请 联系老师 获取答案
您可能会需要:
您的账号:,可能还需要:
您的账号:
发送账号密码至手机
发送
安装优题宝APP,拍照搜题省时又省心!
更多“阅读以下说明和Java程序,将应填入(n)处的字句写在对应栏…”相关的问题
第1题
阅读以下说明、Java代码,将应填入(n)处的字句写在对应栏内。【说明】 本程序输出10000之内的所有完全

阅读以下说明、Java代码,将应填入(n)处的字句写在对应栏内。

【说明】

本程序输出10000之内的所有完全数。完全数是指等于其所有因子和(包括1,但不包括这个数本身)的数。例如:6=1×2×3,6=1+2+3,则6是一个完全数。

【程序】

public class PerfectNum

{

Public static void main(String args[])

{

int count=1;

for(int i=1; i<10000; i++)

{

int y=0;

for(int j=1; j<i; j++)

if((1))

y=(2)

if((3))

{

System.out.print((4) +String.valueOf('\t'));

(5)

If(count%3==0)

System.out.printin();

}

}

}

点击查看答案
第2题
阅读以下说明、Java代码和HTML文档,将应填入(n)处的字句写在答题纸的对应栏内。【说明】 当用户启动h

阅读以下说明、Java代码和HTML文档,将应填入(n)处的字句写在答题纸的对应栏内。

【说明】

当用户启动html浏览器并首次打开下面的HTML文档时,Java Applet小程序在显示面板上显示字符串“Welcome!”;当html页面被其他窗口

遮挡后再次显示时,小程序在显示面板上显示“Welcome back!”。

【Java代码】

import javA.awt.*;

import javA.applet;

public class HelloApplet extends (1) {

public void paim((2)){

g.drawString(message,10,20);

message="welcome back!”;

}

public void (3) (){

message="Welcome!”;

}

private (4) message;

}

【HTML文档】

<html>

<head>

<title>HTML Test HelloApplet Page</title>

</head>

<body>

Test HelloApplet小程序<br>

<applet

codebase="."

code="(5) "

name="TestApplet"

width="400"

height="300"

</applet>

</body>

</html>

点击查看答案
第3题
阅读以下说明、Java代码和HTML文档,将应填入(n)处的字句写在对应栏内。【说明】 当用户启动html浏览

阅读以下说明、Java代码和HTML文档,将应填入(n)处的字句写在对应栏内。

【说明】

当用户启动html浏览器并首次打开下面的html文档时,Java Applet小程序在显示面板上显示字符串“欢迎您!”;当html页面被其他窗口遮挡后再次显示时,小程序在显示面板上显示“欢迎您回来!”

[Java代码]

import java.awt.*;

import java.applet.*;

public class HelloApplet extends (1) {

public void paint((2) ){

g.drawString(message,10,20);

message="欢迎您回来!";

}

public void (3) (){

message="欢迎您!";

}

private (4) message;

}

[HTML文档]

<html>

<head>

<title>HTML Test HelloApplet Page</title>

</head>

<body>

Test HenoApplet 小程序<br>

<applet

codebase="."

code="(5)"

name="TestApplet"

width="400"

height="300"

</applet>

</body>

</html>

点击查看答案
第4题
阅读以下说明和Java代码,将应填入(n)处的字句写在对应栏内。[说明] 编写一个字符界面的Java Appli

阅读以下说明和Java代码,将应填入(n)处的字句写在对应栏内。

[说明]

编写一个字符界面的Java Application 程序,接受用户输入的10个整数,并输出这10个整数的最大值和最小值。

[Java 代码]

import java. io.* ;

public class abc

{

public static void main ((1))

{int i, n=10, max=0, min=0, temp=0;

try {

BufferedReader br = new BufferedReader (

new InputStreamReader (System.in ) );

max = min =Integer. parselnt (br. readLine () );

}. (2) (IOExccption e ) {} ;

for (i=2 ; i<=n ; i++ ) {

try {

BufferedReader br = new (3) (

new InputStreamReader (System. in ) );

temp =(4) (br. readLine ());

if (temp>max ) max=temp;

if (temp<min) (5)

} catch (IOException e ) {};

}

System.out.println ("max="+max+"\nmin="+min );

}

}

点击查看答案
第5题
阅读以下说明和Java程序,将应填入(n)处的字句写在对应栏内。 [说明] 下面程序输出一个矩形面积,

阅读以下说明和Java程序,将应填入(n)处的字句写在对应栏内。

[说明]

下面程序输出一个矩形面积,以及矩形区域上的假想的作物产量。

[Java程序]

public class MainJava {

public static void main(String[] args){

Lot_size small=new Lot_size();

Lot_size medium=new Lot_size();

small.set(5,5,5,25);

medium.set(10,10,10,50);

System.out.println("For a small lot of area"

+small.get_area()+"\n");

System.out.println("the actual crops are $"

+small.get_data2()+"\n");

System.out.println("and ideal crops are $"

+small.get data()+"\n");

System.out.println("For a medium lot of area"

+medium.get_area()+“\n”);

System.out.println("the actual crops are $"

+medium.get_data2()+"\n");

System.out.println ("and ideal crops are $"

+medium.get_data()+"\n");

}

}

class Crop_assessment{

private int actual_crop;

private int ideal_crop;

public void set(int in_actual,int in ideal){

actual_crop=in_actual;

ideal_crop=in_ideal;

}

public int get_actual_crop(){return (1) ;}

public int get_ideal_crop()(return (2) ;}

}

class Lot_size{

private int length;

private int width;

private Crop_assessment crop= (3) ;

public void set(int 1,int W,int a,int i){

length=1;

width=W;

crop.set(a,i);

}

public int get_area(){return length*width;}

public int get_data()freturn (4) ;}

public int get_data2()(return (5) ;}

}

点击查看答案
第6题
阅读以下说明和java代码,将应填入(n)处的字句写在对应栏内。[说明] 本程序中预设了若干个用户名和

阅读以下说明和java代码,将应填入(n)处的字句写在对应栏内。

[说明]

本程序中预设了若干个用户名和口令。用户输入正确的用户名后,可以查找对应的口令,一旦输入结束标记“end”,程序结束。

[Java代码]

import java. io. *:

public class User {

public String user;

public Siring pass;

public User() { }

public User(String u,String p) {

user=u;

pass=p;

}

public String (1) () { return this. user; }

public String (2) () { return this. pass; }

public static void main(String[] args) {

User ua[]={new User("Li","123456"), new User("wang","654321"),

new User("Song","666666")};

while(true) {

InputStreamReader reader = new InputStreamReader(System. in);

BufferedReader inpul = new BnfferedReader(reader);

System. out. print("Enter your name:");

String name = null;

try { name = input. readLine();}

catch (IOException ex) {}

if((3)) break;

int i;

for (i=0;i<3;i++) {

if (name. equals(ua[i]. getUser())){

System. out. println("密码:"+ua[i].getPass());

(4);

}

}

if ((5)) System. out. println("该用户不存在!");

}

}

}

点击查看答案
第7题
阅读以下程序说明和java代码,将应填入(n)处的字句写在对应栏内。[说明] 本程序接收输入的学生信息

阅读以下程序说明和java代码,将应填入(n)处的字句写在对应栏内。

[说明]

本程序接收输入的学生信息,包括学号、姓名、成绩,原样输出信息并计算学生的平均成绩。其中学生类Stud除了包括no(学号)、name(姓名)和grade(成绩)数据成员外,还有两个静态变量 sum和num,分别存放总分和人数,另有一个构造函数、一个普通成员函数disp()和一个静态成员函数avg()用于计算平均分。

[Java代码]

public class Stud {

public int no;

public String name;

public double grade;

public (1) double sum=0;

public static int num=0;

public Stud(int no,String name,double grade) {

this.no = no;

this.name = name;

this.grade = grade;

this.sum=(2);

(3);

}

public static double avg(){

return (4);

}

public void disp(){

System.out.println(this.no+"\t"+this.name+"\t"+this.grade);

}

public static void main(String[] args) {

Stud []students = {new Stud (1,"Li", 81), new Stud(2,"Zhao",84.5), new Stud(3,"Zhang", 87)};

System.out.pfintln("no\tname\tgrade");

students[0].disp();

students[1].disp();

students[2].disp();

System.out.println("avg="+(5));

}

}

点击查看答案
第8题
阅读以下说明和Java代码,将应填入(n)处的字句写在对应栏内。 【说明】 下面的Java程序演示了程序竞

阅读以下说明和Java代码,将应填入(n)处的字句写在对应栏内。

【说明】

下面的Java程序演示了程序竞争资源(Mutex的实例对象)而引起程序死锁的一种例子。

【Java程序】

import java.applet.*;

import java.awt.*;

//此处声明一个互斥类

class Mutex { }

class A extends (1)

{

private Mutex first,second;

public A(Mutex f,Mutex s)

{

first = f;

second = s;

}

public void run()

{

//锁定first变量

(2) (first)

{

try

{ //本线程挂起,等待重新调度

Thread.sleep(1); //注意此处(1)不是小题序号

}

catch(InterruptedException e){}

System. out. println("threadA got first mutex");

(2) (second) //锁定second变量

{ //do something

System. out. println("threadA got second mutex");

} //释放second变量

} //释放first变量

}

}

class B extends (1)

{

private Mutex first,second;

public B(Mutex f,Mutex s)

{

(3) ;

second = s;

}

public void run()

{

(2) (second) //锁定second变量

{

//do something

try

{

Thread.sleep(((int)(3*Math.random()))*1000);

//本线程挂起,等待重新调度

}

catch(InterruptedException e){}

System.out.println("threadB got second mutex");

(2) (first) //锁定first变量

{

//do something

System.out.println("threadB got first mutex");

} //释放first变量

} //释放second变量

}

}

public class DeadlockExample

{

public static void main(String arg[])

{

Mutex mutexX = new Mutex();

Mutex mutexY = new Mutex();

AthreadA = new A(mutexX,mutexY);

B threadB = new B (4);

threadA.(5);

threadB.start();

}

}

点击查看答案
第9题
阅读以下说明和Java代码,将应填入(n)处的语句写在对应栏内。 【说明】 进行两个整数之间的比较,由考

阅读以下说明和Java代码,将应填入(n)处的语句写在对应栏内。

【说明】

进行两个整数之间的比较,由考生通过输入窗口分别输入两个整数,程序比较出结果。例如:先后输入的两个数分别为25和36。

比较结果显示:

25!=36

25<36

25<=36

【Java代码】

import javax.swing.JOptionPane;

public class Java3

{

public static void main(String args[])

{

String (1) // 用户输入第1个字符串

secondNumber, // 用户输入第2个字符串

result; // 包含输出

int number1, // 比较的第1个数

number2; // 比较的第2个数

// 用户输入的第1个字符串

firstNumber =

JOptionPane. (2) ("Enter first integer:");

//读用户输入的第2个字符串

secondNumber =

JOptionPane.showlnputDialog("Enter second integer:");

将字符串类型转换成整数类型

number1= Integer. (3) (firstNumber);

number2= Integer.parselnt(secondNumber);

result= "":

if ((4))

result=number1+"=="+number2;

if (number1 != number2)

result=number1+"!="+number2;

if (number1<number2)

result=result+"\n"+number1+"<"+ number2;

if (number1>number2)

result=result+"\n"+number1+">"+number2;

if (number1<=number2)

result=result+"\n"+number1+"<="+number2;

if (numbed>=number2)

result=result+"\n"+number1+">="+number2;

//显示结果

JOptionPane.(5).(

null, result, "Comparison Results",

JOptionPane. INFORMATION_MESSAGE);

//程序正常退出

System.exit(0);

}

}

点击查看答案
第10题
试题八(共15分)阅读以下说明和Java程序代码,将应填入(n) 处的字句写在答题纸的对应栏内。[说明]在

试题八(共15分)

阅读以下说明和Java程序代码,将应填入(n) 处的字句写在答题纸的对应栏内。

[说明]

在下面的 Java 程序代码中,类SalesTicket 能够完成打印票据正文的功能,类HeadDecorator 与FootDecorator 分别完成打印票据的台头和脚注的功能。已知该程序运行后的输出结果如下所示,请填补该程序代码中的空缺。这是票据的台头!这是票据正文!这是票据的脚注!------------------------这是票据的台头!

这是票据的脚注!

[Java程序代码]

public class SalesTicket {

public void printTicket() {

System.out.println("这是票据正文!");

}

}

public class Decorator extends SalesTicket{

SalesTicket ticket;

}

}

public class FootDecorator extends Decorator{

public FootDecorator(SalesTicket t) {

(2) ;

}

public void printTicket() {

super.printTicket();

System.out.println("这是票据的脚注!");

}

}

public class Main {

public static void main(String[] args) {

T = new HeadDecorator((3) );

T. (4) ;

System.out.println("------------------------");

T = new FootDecorator((5) );

T.printTicket();

}

}

public Decorator(SalesTicket t){

ticket = t;

}

public void printTicket(){

if(ticket != null)

ticket.printTicket();

}

}

public class HeadDecorator extends Decorator{

public HeadDecorator(SalesTicket t) {

(1) ;

}

public void printTicket() {

System.out.println("这是票据的台头!");

super.printTicket();

点击查看答案
退出 登录/注册
发送账号至手机
密码将被重置
获取验证码
发送
温馨提示
该问题答案仅针对搜题卡用户开放,请点击购买搜题卡。
马上购买搜题卡
我已购买搜题卡, 登录账号 继续查看答案
重置密码
确认修改