单选题public class Foo {  static int[] a;  static { a[0]=2; }  public static void main( String[] args) {}  }  Which exception or error will be thrown when a programmer attempts to run this code?()A  java.lang. StackOverflowErrorB  java.lang.IllegalStateExcep

题目
单选题
public class Foo {  static int[] a;  static { a[0]=2; }  public static void main( String[] args) {}  }  Which exception or error will be thrown when a programmer attempts to run this code?()
A

 java.lang. StackOverflowError

B

 java.lang.IllegalStateException

C

 java.lang.ExceptionlnlnitializerError

D

 java.lang.ArraylndexOutOfBoundsException

如果没有搜索结果或未解决您的问题,请直接 联系老师 获取答案。
相似问题和答案

第1题:

public class Foo implements Runnable (  public void run (Thread t) {  system.out.printIn(“Running.”);  }  public static void main (String[] args)  {  new thread (new Foo()).start();  } )   What is the result?()      

  • A、 An exception is thrown.
  • B、 The program exists without printing anything.
  • C、 An error at line 1 causes compilation to fail.
  • D、 An error at line 2 causes the compilation to fail.
  • E、 “Running” is printed and the program exits.

正确答案:D

第2题:

Which declarations will allow a class to be started as a standalone program?()  

  • A、public void main(String args[])
  • B、public void static main(String args[])
  • C、public static main(String[] argv)
  • D、final public static void main(String [] array)
  • E、public static void main(String args[])

正确答案:D,E

第3题:

Give the following java class:public class Example{public static void main(String args[]){int x[] = new int[15];System.out.println(x[5]);}}Which statement is corrected?()

A.When compile, some error will occur.

B.When run, some error will occur.

C.Output is zero.

D.Output is null.


参考答案:C

第4题:

public class Foo {  static int[] a;  static { a[0]=2; }  public static void main( String[] args) {}  }  Which exception or error will be thrown when a programmer attempts to run this code?() 

  • A、 java.lang. StackOverflowError
  • B、 java.lang.IllegalStateException
  • C、 java.lang.ExceptionlnlnitializerError
  • D、 java.lang.ArraylndexOutOfBoundsException

正确答案:C

第5题:

public class Foo implements Runnable (  public void run (Thread t) {   system.out.printIn(“Running.”);   }   public static void main (String args) {   new thread (new Foo()).start();   }   )   What is the result?()  

  • A、 An exception is thrown.
  • B、 The program exists without printing anything.
  • C、 An error at line 1 causes compilation to fail.
  • D、 An error at line 6 causes the compilation to fail.
  • E、 “Running” is printed and the program exits.

正确答案:C

第6题:

public class Test {   public static void main (String args) {  string foo = “blue”;  string bar = foo;   foo = “green”;   System.out.printIn(bar);   }   }   What is the result?()  

  • A、 An exception is thrown.
  • B、 The code will not compile.
  • C、 The program prints “null”
  • D、 The program prints “blue”
  • E、 The program prints “green”

正确答案:D

第7题:

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

第8题:

以下是JAVA中正确的入口方法是? () 

  • A、 public static void main(String[] args){}
  • B、 public static void main(String args){}
  • C、 public void main(String[] args){}
  • D、 public static int main(String[] args){}

正确答案:A

第9题:

public class Test {  public static void main(String[] args) {  String str = NULL;  System.out.println(str);  }  }   What is the result?()  

  • A、 NULL
  • B、 Compilation fails.
  • C、 The code runs with no output.
  • D、 An exception is thrown at runtime.

正确答案:B

第10题:

11. class Converter {  12. public static void main(String[] args) {  13. Integer i = args[0];  14. int j = 12;  15. System.out.println(”It is “ + (j==i) + “that j==i.”);  16. }  17. }  What is the result when the programmer attempts to compile the code and run it with the command java Converter 12?() 

  • A、 It is true that j==i.
  • B、 It is false that j==i.
  • C、 An exception is thrown at runtime.
  • D、 Compilation fails because of an error in line 13.

正确答案:D

更多相关问题