首页 > 计算机等级考试
题目内容 (请给出正确答案)
[主观题]

阅读下面程序 1 public class Try extends Thread{ 2 public static void main(String args[]

阅读下面程序 1 public class Try extends Thread{ 2 public static void main(String args[]){ 3Try t=new Try; 4 t.start; 5} 6 7 public void run(intj){ 8 inti=0; 9 while(i<5){ 10 System.out.println("祝你成功!"); 11 i++: 12} 13} 14} 该程序要求打印5行"祝你成功!",必须改正程序中的某行代码,程序才能完成。选择正确的修改是()。

A.将第1行的extendsThread改为implementsRunnable

B.将第3行的newTry改为newThread

C.将第4行t.start改为start(t)

D.将第7行的public void run(intj)改为public void run

查看答案
答案
收藏
如果结果不匹配,请 联系老师 获取答案
您可能会需要:
您的账号:,可能还需要:
您的账号:
发送账号密码至手机
发送
安装优题宝APP,拍照搜题省时又省心!
更多“阅读下面程序 1 public class Try exte…”相关的问题
第1题
阅读下面程序public class Test4 { public static void main(String[] args) { int 1=10,j=3;

阅读下面程序 public class Test4 { public static void main(String[] args) { int 1=10,j=3; float m=213.5f,n=4.0f; System.out.println(i%j); System.out.println(m%n); } } 程序运行的结果是

A.1.0和1.5

B.1和1.5

C.1.0和2.5

D.1和2.5

点击查看答案
第2题
请阅读下面程序public class Test {public static void main (String[] args) {int i,j;for (i=1

请阅读下面程序

public class Test {

public static void main (String[] args) {

int i,j;

for (i=1;i<5;i++) {

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

system.out.print (i+"X"+j+"="+i*j+" ");

System.out.println();

}

}

}

程序执行完后,i循环和j循环执行的次数分别是【 】。

点击查看答案
第3题
(18 )请阅读下面程序/.public class ForLoopStatement {public static void main (String[] ar

(18 )请阅读下面程序/.

public class ForLoopStatement {

public static void main (String[] args ){

int I,j :

for (i=l;i<5;i++ ){ //i 循环

for (j=1;j<=i;j++ ) //j 循环

System.out.print (i+" X "+j+ ” = +i*j+" ” );

System.out.println () ;

}

程序完成后, i 循环和 j 循环执行的次数分别是

A ) 4 , 10

B ) 8 , 9

C ) 9, 8

D ) 10 , 10

点击查看答案
第4题
阅读下面代码: import java.awt.*; public class Exam11_1 {private Frame. f;private Button b1

阅读下面代码:

import java.awt.*;

public class Exam11_1

{

private Frame. f;

private Button b1,b2,b3,b4;

public static void main(String args[]

{

Exam11_1 that = new Exam11 1 ();

that.go();

}

public void go()

{

______;

f.setLayout(new FlowLayout()) ;;

b1 = new Button ("Button 1");

b2 = new Button ("Button 2");

b3 = new Button ("Button 3");

b4 = new Button ("Button 4");

f.add (b1);

f.add (b2);

f.add (b3);

f.add (b4);

f.pack ();

f.setVisible (true);

}

}

请在程序中画线处填写正确的语句【 】,以便编译运行程序后得到正确的结果。

点击查看答案
第5题
阅读下面程序1 public class Try extends Thread {2 public static void main(String args[]) {3

阅读下面程序 1 public class Try extends Thread { 2 public static void main(String args[]) { 3 Try t=new Try(); 4 t.start(); 5 } 6 7 public void run(int j) { 8 int i=0; 9 while(i<5) { 10 System.out.println("祝你成功!"); 11 i++: 12 } 13 } 14 } 该程序若能打印5行“祝你成功!”,必须改正程序中的某行代码,选择正确的修改是

A.将第1行的extends Thread改为implements Runnable

B.将第3行的new Try()改为new Thread()

C.将第4行的t.start()改为start(t)

D.将第7行的public void run(int j)改为public void run()

点击查看答案
第6题
阅读下面程序1public class Try extends Thread{2public static void main(String args[]){3Try

阅读下面程序 1 public class Try extends Thread{ 2 public static void main(String args[]){ 3 Try t=new Try(); 4 t.start(); 5 } 6 7 public void run(int j){ 8 int i=0; 9 while(i<5){ 10 System.out.println(“祝你成功!”); 11 i++; 12 } 13 } 14 } 该程序要求打印5行“祝你成功!”,必须改正程序中的某行代码,程序才能完成。选择正确的修改是

A.将第1行的extends Thread改为implements Runnable

B.将第3行的new Try()改为new Thread()

C.将第4行t.start()改为start(t)

D.将第7行的public void run(int j)改为public void run()

点击查看答案
第7题
阅读下面程序1public class Try extends Thread{2public static void main(String args[]){3Try

阅读下面程序 1 public class Try extends Thread{ 2 public static void main(String args[]){ 3 Try t=new Try(); 4 t.start(); 5 } 6 7 public void run(int j){ 8 int i=0; 9 while(i<5){ 10 System.out.println(“祝你成功!”); 11 i++; 12 } 13 } 14 } 该程序要求打印5行“祝你成功!”,必须改正程序中的某行代码,程序才能完成。选择正确的修改是

A.将第1行的extends Thread改为implements Runnable

B.将第3行的new Try()改为new Thread()

C.将第4行t.start()改为start(t)

D.将第7行的public void run(int j)改为public void run()

点击查看答案
第8题
阅读下面利用递归来求n!的程序class FactorialTest { static long Factorial(int n){ //定义F

阅读下面利用递归来求n!的程序 class FactorialTest { static long Factorial(int n){ //定义Factorial()方法 if(n==1)return 1; else return n * Factorial(______); } public static void main(String a[]) { //main()方法 int n=8; System.out.println(n+"!="+Factorial(n)); } } 为保证程序正确运行,在下画线处应该填入的参数是

A.n-1

B.n-2

C.n

D.n+1

点击查看答案
第9题
3阅读下面程序1public class Try extends Thread{ 2public static void main(String args[ ]){ 3

3阅读下面程序 1 public class Try extends Thread{ 2 public static void main(String args[ ]){ 3 Try t = new Try(); 4 t.start(); 5 } 6 7 public void run(int j){ 8 int i = 0; 9 while(i<5) { 10 System.out.pfintln("祝你成功"); 11 i++; 12 } 13 } 14 } 该程序要求打印5行“祝你成功”必须改正程序中的某行代码,程序才能完成。选择正确的修改是()。

A.将第1行的extends Thread改为implements Runnable

B.将第3行的new Try()改为new Thread()

C.将第4行t.sta.rt()改为start(t)

D.将第7行的publ void run(int j)改为public void run()

点击查看答案
第10题
阅读以下说明和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) ;}

}

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