网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)

找出错误并修改下面的代码: public class Test{ public static void main(String[] args){ double[100] r; for(int i = 0; i < r.length(); i++); r(i) = Math.random * 100; } }指出错误代码的位置,并写出修改后的正确代码。提交的作业内容中的程序代码以代码格式提交(如题目中的代码)。


参考答案和解析
错误语句: void Subtract_C(Complex Sub,Complex c1,Complex c2) 真确的: void Subtract_C(Complex &Sub,Complex c1,Complex c2) 少写了一个& 详细见第一章中给出的课件 第0章 C++复习.ppt
更多 “找出错误并修改下面的代码: public class Test{ public static void main(String[] args){ double[100] r; for(int i = 0; i < r.length(); i++); r(i) = Math.random * 100; } }指出错误代码的位置,并写出修改后的正确代码。提交的作业内容中的程序代码以代码格式提交(如题目中的代码)。” 相关考题
考题 以下代码的运行结果是______。public class exl5{public static void main(String args []){int i = 5;do{i--;if(i > 2)continue;}while(i < 0);System.out.println(i);}}

考题 下面代码段的输出结果为( )。 public class Test { public static void main(String sss[]) { int i=0xFFFFFFFl; int j=~i; } }A.0B.1C.14D.-15

考题 下列代码的执行结果是( )。 public class Test { public static void main ( String args[]) { float f=5.0f; int i=4; System.out.println((f++) *(--i)); } }A.20B.20.0C.15D.15.0

考题 已知如下类说明: public class Test { private float f = 1.0f; int m = 12; static int n=1; public static void main(String arg[]) { Test t = new Test(); // 程序代码… } } 如下哪个使用是正确的?() A.t.fB.this.nC.Test.mD.Test.n

考题 下列程序的执行结果是 ( ) public class Test { public int aMethod() { satic int i=0; i++; System.out.println(i); } public static void.main(String args[]) { Test test=new Test(); test.aMethod(); }A.编译错误B.0C.1D.运行成功,但不输出

考题 在下列代码的下i画线处应填人的内容是( )。 public class FirstSample{ public static void main( args[]){ System.out.println("你好!"); } }A.staffB.doubleC.intD.String

考题 阅读以下说明和Java代码,回答问题1和问题2,将解答填写在对应栏内。【Java代码】class usethread implements (1) {int numusethread(int n){num=n;}public void (2) {for(int i=0;i<3;i++)System.out.println("running:"+num);System.out.println("finished:"+num);}public class multhread{public static void main(String args[]) (3) InterruptedException{Thread m1=new Thread(new usethread(1));Thread m2=new Thread(new usethread(2));m1.start();m2.start();m1.join();m2.join();}}【问题1】补充完整上面Java代码中(n)处。【问题2】写出上面Java代码运行的结果。

考题 下列代码的执行结果是public class Test{ public int aMethod(){ static int i=0; i++; System.out.println(i); } public static void main(String args[]){ Test test= new Test(); test. aMethod(); }}A.编译错误B.0C.1D.运行成功,但不输出

考题 下列程序的执行结果是______。 public class ex3 { public static void main(String[] args) { int sum=0; for(int i=1;i<=100;i++) { sum+=i; } System.out.println("sum="+sum); }A.sum=5050B.sum=4950C.sum=100D.sum=1

考题 下面代码的运行结果是 public class Test{ public static void main(String args[]){ for(int i=0; i<3;i++){ if(i<2) continue; System.out.println(i); } } }A.0B.1C.2D.3

考题 下面程序代码运行结果为( )。 import java.awt.*; public class Test { public static void main (String args[]) { String s1="a+b+c"; String s2="+"; int i=s1.lastIndexOf (s2); System.out.println(i); } }A.0B.1C.2D.3

考题 在下面程序的下画线处应填入的选项是 public class Test______{ public static void main(String args[]) { Test t=new Test(); Thread tt=new Thread(t); tt.start(); } public void run() { for(int i=0;i<5;i++) System.out.println("i="+i); } }A.implements RunnableB.extends ThreadC.implements ThreadD.extends Runnable

考题 下列程序输出结果为( )。public class test { public static void main(String args[]) { int a=0; outer: for(int i=0;i<2;i++) { for(int j=0;j<2;j++) { if(j>i) { continue outer; } a++; } } System.out.println(a); }}A.0B.2C.3D.4

考题 下列代码的执行结果是( )。public class Test{public int aMethod( ){static int i=0;i++;System.out.println(i):}public static void main (String args[]){Trest test=new Test ( );test aMethod( ):}}A.编译错误B.0C.1D.运行成功,但不输出B.C.D.

考题 下列代码的执行结果是 public class Test{ public int aMethod( ) { static int i=0; i+ +; System.out.println(i); } public static void main(String args[ ]){ Test test = new Test( ); test.aMethod( ); } }A.编译错误B.0C.1D.运行成功,但不输出

考题 当你编译运行下列程序代码,会得到什么结果?private class Base{ Base(){ int i = 100; System.out.println(i); } }public class Pri extends Base{ staticint i = 200;public static void main(String argv[]){ Pri p = new Pri(); System.out.println(i); } }A.这段代码不能通过编译B.输出200C.输出100和200D.输出100

考题 下列的程序的功能是求2~100之间的素数,程序中划线部分应填入的选项是 public class Testnn { public static void main(String args[]) { Labell: for(int i=2;i100;i++) { for(int j=2;j<i;j++) { if(i%j==______)continue Labell; } System.out.println(i); } } }A.0B.1C.iD.j

考题 阅读以下说明和 Java 代码,填补代码中的空缺,将解答填入答题纸的对应栏内。 【说明】 设计 RGB 方式表示颜色的调色板,进行绘图。其类图如图 6-1 所示。该程序的 Java代码附后。图6-1 类图【Java 代码】 //颜色类 class MyColor { private int red ,green, blue; public MyColor( ) { red = o; green = 0; blue = 0; } public MyColor(int red ,int green ,int blue) { this.red = red; this.green = green; this.blue = blue; } //其他方法略 public String toString( ) { return Red: + red + \tGreen: + green + \tBlue + blue; } } //调色板类 class Palette { public int number; / /颜色数 private (1)palette; //颜色表 public Palette( ) { number = 256; palette = new MyColor[number); } public Palette(MyColor[] palette ,int number) { (2)= number; (3)= palette; } //其他方法略 public String toString( ) { String str = ; for (int i = 0; i number; i++) { str +=i+ : + palette[i] + \n; } return str; } //绘图类 class Drawing { public (4) int COLORNUMBER = 16; public static void main(String[] args) { Palette palette; int red ,green ,blue; MyColor[] color = new MyColor[COLORNUMBER]; for (int i = 0; i COLORNUMBER; i++) { red = (int) (Math.random( ) * 256); green = (int) (Math.random( ) * 256); blue = (int) (Math.random( ) * 256); color [i] = (5) (red ,green ,blue); } palette = new Palette(color ,COLORNUMBER); System.out.println(palette); } }

考题 设有如下代码:class Base{}public class MyCast extends Base{static boolean b1=false;static int i = -1;static double d = 10.1;public static void main(String argv[]){MyCast m = new MyCast();Base b = new Base();//Here}}则在 //Here处插入哪个代码将不出现编译和运行错误。A.b=m;B.m=b;C.d =i;D.b1 =i;

考题 ( 30 )在程序的下划线处应填入的选项是public class Test _________{public static void main(String args[]){Test t = new Test();Thread tt = new Thread(t);tt.start();}public void run(){for(int i=0;i5;i++){system.out.println( " i= " +i);}}}A ) implements RunnableB ) extends ThreadC ) implements ThreadD ) extends Runnable

考题 public class test3  {  public static void main(String args[])  {           for(int i = 0; i  3; i++)  {  for(int j = 3; j = 0; j--)  {                if(i == j)                    continue;       System.out.println("i="+ i + " j="+j);       }    }       }  }  上面的Java代码编译运行后,下列选项中,()会出现在输出结果中。 A、i=0 j=3B、i=0 j=0C、i=2 j=2D、i=0 j=2E、i=1 j=2

考题 研究下面的Java代码:  public class testException{  public static void main(String args[]){       int a[]={0,1,2,3,4};      int sum=0;      try{  for(int i=1;i6;i++)  sum=sum+a[i];  System.out.println("sum="+sum);                 }      catch(ArrayIndexOutOfBoundsException ){                    System.out.println("数组越界");     }  finally{   System.out.println("程序结束");}  } }  输出结果将是()。       A、10  数组越界  程序结束B、10   程序结束C、数组越界  程序结束D、程序结束

考题 public class Foo {   public static void main (String args) {   int i = 1;   int j = i++;   if ((i++j)  (i++ ==j)) {   i +=j;   }   }   }   What is the final value of i?()  A、 1B、 2C、 3D、 4E、 5

考题 对于下列代码: 1) class Person {   2} public void printValue(int i, int j) {//... }     3} public void printValue(int i){//... }    4} }   5) public class Teacher extends Person { 6} public void printValue( ) {//... }     7} public void printValue(int i) {//...}     8} public static void main(String args[]){     9} Person t = new Teacher( );     10} t.printValue(10);     11} } 第10行语句将调用哪行语句?()A、 line 2B、 line 3C、 line 6D、 line 7

考题 public class Test {  public int aMethod() {  static int i = 0;  i++;  return i;  }  public static void main (String args[]) {  Test test = new Test();  test.aMethod();  int j = test.aMethod();  System.out.println(j);  }  }  What is the result?()  A、 0B、 1C、 2D、 Compilation fails.

考题 单选题public class Test {  public int aMethod() {  static int i = 0;  i++;  return i;  }  public static void main (String args[]) {  Test test = new Test();  test.aMethod();  int j = test.aMethod();  System.out.println(j);  }  }  What is the result?()A  0B  1C  2D  Compilation fails.

考题 单选题public class test(    public int aMethod()[   static int i=0;   i++;   return I;   )    public static void main (String args){   test test = new test();    test.aMethod();   int j = test.aMethod();   System.out.printIn(j);   ]  }   What is the result?()A  Compilation will fail.B  Compilation will succeed and the program will print “0”C  Compilation will succeed and the program will print “1”D  Compilation will succeed and the program will print “2”

考题 多选题public class test3  {  public static void main(String args[])  {           for(int i = 0; i = 0; j--)  {                if(i == j)                    continue;       System.out.println("i="+ i + " j="+j);       }    }       }  }  上面的Java代码编译运行后,下列选项中,()会出现在输出结果中。Ai=0 j=3Bi=0 j=0Ci=2 j=2Di=0 j=2Ei=1 j=2