public class Alpha{  private static Character() ids;  public static void main( String[] args){  ids = new Character[args.length];  for (int i=0; iids[i] = new Character( args[i] );  System.out.print( ids[i] );  }  }  }   What is correct?()   A、 Compilati

题目

public class Alpha{  private static Character() ids;  public static void main( String[] args){  ids = new Character[args.length];  for (int i=0; iids[i] = new Character( args[i] );  System.out.print( ids[i] );  }  }  }   What is correct?()  

  • A、 Compilation fails.
  • B、 The code runs with no output.
  • C、 An exception is thrown at runtime.
  • D、 The code runs, outputing a concatenated list of the arguments passed to the program.
参考答案和解析
正确答案:A
如果没有搜索结果或未解决您的问题,请直接 联系老师 获取答案。
相似问题和答案

第1题:

public class Something {

public static void main(String[] args) {

Other o = new Other();

new Something().addOne(o);

}

public void addOne(final Other o) {

o.i++;

}

}

class Other {

public int i;

}

和上面的很相似,都是关于final 的问题,这有错吗?


正确答案:

 

正确。在addOne method 中,参数o 被修饰成final。如果在addOne method 里我们修

改了o 的reference

(比如: o = new Other();),那么如同上例这题也是错的。但这里修改的是o 的member vairable

(成员变量),而o 的reference 并没有改变。

第2题:

以下程序的输出结果为:public class example {public static void main(String args[]) {int i=0;for (i=0;i<4;i++) {if (i==3、break;System.out.print(i);}System.out.println(i);}}

A.0123 B.0122 C.123 D.234


正确答案:A

第3题:

publicclassAlpha{privatestaticCharacter()ids;publicstaticvoidmain(String[]args){ids=newCharacter[args.length];for(inti=0;iids[i]=newCharacter(args[i]);System.out.print(ids[i]);}}}Whatiscorrect?()

A.Compilationfails.

B.Thecoderunswithnooutput.

C.Anexceptionisthrownatruntime.

D.Thecoderuns,outputingaconcatenatedlistoftheargumentspassedtotheprogram.


参考答案:A
Compilationfails.Line2:ReturnTyperequired.

第4题:

class Super {  public int i = 0;  public Super(String text) {  i = 1; }  }  public class Sub extends Super {  public Sub(String text) {  i = 2;  }   public static void main(String args[]) {  Sub sub = new Sub(“Hello”);  System.out.println(sub.i);  }  }  What is the result?()  

  • A、 0
  • B、 1
  • C、 2
  • D、 Compilation fails.

正确答案:C

第5题:

( 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;i<5;i++){

system.out.println( " i= " +i);

}

}

}

A ) implements Runnable

B ) extends Thread

C ) implements Thread

D ) extends Runnable


正确答案:A

第6题:

下列代码的执行结果是( )。

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.0

C.1

D.运行成功,但不输出

B.

C.

D.


正确答案:A

第7题:

以下程序的运行结果为?

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.10030

B. 20030

C. 209930

D. 10020


正确答案:D

第8题:

下列代码的执行结果是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.0

C.1

D.运行成功,但不输出


正确答案:A
解析:static不能修饰局部变量。

第9题:

public class Test {  public static void add3 (Integer i) {  int val = i.intValue();  val += 3;  i = new Integer(val); }  public static void main(String args[]) {  Integer i = new Integer(0);  add3(i);  System.out.println(i.intValue());  }  }   What is the result? () 

  • A、 0
  • B、 3
  • C、 Compilation fails.
  • D、 An exception is thrown at runtime.

正确答案:A

第10题:

public class test (   public static void main(string args) {   int 1= 0;   while (i) {   if (i==4) {   break;  }   ++i;  }   }   )   What is the value of i at line 10?()

  • A、 0
  • B、 3
  • C、 4
  • D、 5
  • E、 The code will not compile.

正确答案:E

更多相关问题