在注释//Start For loop 处要插入哪段代码可实现根据变量i的值定位数组ia[]的元素?public class Lin{public void amethod(){int ia[] = new int[4];//Start For loop{ia[i]=i;System.out.println(ia[i]);}}} A. for (int i=0; iB. for (int i=0; iC. for (int i=1; iD. for (int i=0; i

在注释//Start For loop 处要插入哪段代码可实现根据变量i的值定位数组ia[]的元素?public class Lin{public void amethod(){int ia[] = new int[4];//Start For loop{ia[i]=i;System.out.println(ia[i]);}}}

A. for (int i=0; i< ia.length() -1; i++)

B. for (int i=0; i< ia.length(); i++)

C. for (int i=1; i< 4; i++)

D. for (int i=0; i< ia:A.length;i++)


相关考题:

下面程序段的输出结果是( )。 public class Test {public static void main(String args[]){ int[] a=new int[11]; int[] p=new int[4]; int k=5; for(int i= 1 ; i<= 10;i++) a[i]=i; for(int i=1 ; i<=3;i++) p[i]=a[i*i]; for(int i= 1 ;i<=3;i++) k=k+p[i]*2; System.out.println(k); }}A.37B.31C.33D.35

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

( 24 )请阅读下面程序public class ThreadTest {public static void main ( String args[ ]){Thread t1 = new Thread ( new Hello ()):Thread t2 = new Thread ( new Hello ()):t l .start ():t2.start ();}}class Hello implements Runnable {int i ;public void run (){while ( true ) {System.out.println ( "Hello"+i++ ) ;if ( i=5 ) break :}}}该程序创建线程使用的方法是()A )继承 Thread 类B )实现 Runnable 接口C ) t l.start ()D ) t2.start ()

( 28 )请阅读下面程序public class ThreadTest {public static void main ( String args[ ]) throws Exception {int i=0;Hello t = new Hello ();___________;whlle ( true ){System.out.println ( "Good Morning"+i++ ) ;if ( i=2 && t.isAlive ()){System.out.println ( "Main waiting for Hello ! ” );tjoin () ; // 等待 t 运行结束}if ( i==5 ) break :}}}class Hello extends Thread {int i ;public void run ()笼while ( true ){System.out.println ( "Hello"+i++ ) ;if ( i=5 ) break ;}}}为使该程序正确执行,下划线处的语句应是A ) t.sleep ()B ) t.yieldn ()C ) t.interrupt ()D ) t.start ()

下列程序的执行结果是 ( ) 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.运行成功,但不输出

下面程序输出的结果是【 】。 include using namespacc std; class A { public:void sho 下面程序输出的结果是【 】。include <iostream>using namespacc std;class A {public:void show(){tout<<"A!";}};class B: public A{public:virtual void show(){cout<<"B!";}};class C: public B{public:virtual void show(){cout<<"C!";}};void show_info(A *i){i->show();}void main(){A ia;B ib;C ic;show_info(ia); show_info(ib);show_info(ic);}

请阅读下面程序 public class ThreadTest{ public static void main(String args[])throws Ex- ception{ int i=0; Hello t=new Hello; ; while(true){ System.Out.println("Good Morning"+i++): if(i= =2t.isAlive){ System.out.println("Main waiting for Hel- lo!"); join;//等待t运行结束 } if(i= =5)break;} } } class Hello extends Thread{ int l; public void run{ while(true)( System.Out.println("Hell0"+i++); if(i= =5)break;)))A.t.sleepB.t.yieldC.t.interruptD.t.start

阅读以下说明和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.运行成功,但不输出

阅读下面程序 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 RunnableB.将第3行的new Try()改为new Thread()C.将第4行t.start()改为start(t)D.将第7行的public void run(int j)改为public void run()

阅读下面程序 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 RunnableB.将第3行的new Try()改为new Thread()C.将第4行的t.start()改为start(t)D.将第7行的public void run(int j)改为public void run()

在下面程序的下画线处应填入的选项是 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

运行下列程序的结果是 ( ) abstract class MineBase { abstract void amethod(); static int i; } public class Mine extends MineBase { public static void main(String argv[]){ int[]ar=new int[5]; for(i=0;i<ar.length;i++) System.out.println(ar[i]);A.打印5个0B.编译出错,数组ar[]必须初始化C.编译出错,Mine应声明为abstractD.出现IndexOutOfBoundes的例外

在程序的下画线处应填入的选项是( )。 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

下面程序输出的结果是【 】。 include using namespace std; class A { public:virtual 下面程序输出的结果是【 】。include <iostream>using namespace std;class A {public:virtual void show() {cout<<"A!";};class B: public A {public:void show() {cout << "B!";}};class C: public B{public:void show(){cout << "C!";}};void show_info(A i) {i. show();}void main() {A ia; B ib; C ic; show_info(ia);show_info(ib); show_info(ic); }

下面程序的输出结果是( )。 public class Sun { public static void main(String args[ ]) { int[] a=new int[11]; int[] p=new int[4]; int k=5; for(int i=1;i=10;i++) a[i]=i; for(int i=1;i=3;i++) p[i]=a[i*i]; for(int i=1;i=3;i++) k=k+p[i]*2; System.out.println(k);; } }A.33B.28C.35D.37

下列代码的执行结果是( )。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 static void main(String args[]){ int[]a=new int[113; int[]p=new int[43; int k=5: for(int i=1;i=10;i++) a[i]=i; for(int i=1;i=3;i++) p[i]=a[i*i]; for(int i=1;i=3;i++) k=k+p[i]*2; System.out.println(k); } }A.37B.31C.33D.35

请阅读下面程序,说明该程序创建线程使用的方法是( )。 public class ThreadTest { public static void main(String args[]) { Thread tl=new Thread(new HolloWorld); Thread t2=new Thread(new HolloWorld); tl.start; t2.Start; } } class HolloWorld implements Runnable { int i; public void run { while(true) { System.out.println("HolloWorld"+i++); if(i= =5)break; } } }A.继承Thread类B.实现Runnable接口C.tl.startD.t2.start

以下的程序的调试结果为?public class MyAr{public static void main(String argv[]) {MyAr m = new MyAr();m.amethod();}public void amethod(){static int i;System.out.println(i);}} A. 输出结果为 0B. 运行出错C. 输出结果为 nullD. 编译错误

以下程序的运行结果为?class ValHold{public int i = 10;}public class ObParm{public static void main(String argv[]){ObParm o = new ObParm();o.amethod();}public void amethod(){int i = 99;ValHold v = new ValHold();v.i=30;another(v,i);System.out.print( v.i );}public void another(ValHold v, int i){i=0;v.i = 20;ValHold vh = new ValHold();v = vh;System.out.print(v.i);System.out.print(i);}}A.10030B. 20030C. 209930D. 10020

( 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

现有: class TestApp{ public static void main (String[] args){ for (int i=0; iA、0123B、012456789C、0123456789D、012

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 TestFive {  private int x;  public void foo() {  int current = x;  x = current + 1;  }  public void go() {  for(int i=0;i5;i++) {  new Thread() {  public void run() {  foo();  System.out.print(x + “, “);  } }.start();  }}}  Which two changes, taken together, would guarantee the output: 1, 2, 3, 4, 5, ?()AMove the line 12 print statement into the foo() method.BChange line 7 to public synchronized void go() {.CChange the variable declaration on line 3 to private volatile int x;.DWrap the code inside the foo() method with a synchronized( this ) block.EWrap the for loop code inside the go() method with a synchronized block synchronized(this) { // for loop code here }.

单选题现有: class TestApp{ public static void main (String[] args){ for (int i=0; iA0123B012456789C0123456789D012