public class foo {   public static void main (Stringargs) { 

题目
单选题
public class foo {   public static void main (Stringargs) {  String s;   system.out.printIn (“s=” + s);   }   }   What is the result?()
A

 The code compiles and “s=” is printed.

B

 The code compiles and “s=null” is printed.

C

 The code does not compile because string s is not initialized.

D

 The code does not compile because string s cannot be referenced.

E

 The code compiles, but a NullPointerException is thrown when toString is called.

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

第1题:

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

第2题:

public class Base {  public static final String FOO = “foo”;  public static void main(String[] args) {  Base b = new Base();  Sub s = new Sub();  System.out.print(Base.FOO);  System.out.print(Sub.FOO);  System.out.print(b.FOO);  System.out.print(s.FOO);  System.out.print(((Base)s).FOO);  } }  class Sub extends Base {public static final String FOO=bar;}  What is the result?() 

  • A、 foofoofoofoofoo
  • B、 foobarfoobarbar
  • C、 foobarfoofoofoo
  • D、 foobarfoobarfoo
  • E、 barbarbarbarbar
  • F、 foofoofoobarbar
  • G、 foofoofoobarfoo

正确答案:D

第3题:

以下哪个是Java应用程序main方法的有效定义?

A. public static void main();

B. public static void main( String args );

C. public static void main( String args[] );

D. public static void main( Graphics g );

E. public static boolean main( String a[] );


正确答案:C

第4题:

作为类中新线程的开始点,线程的执行是从()方法开始的。

  • A、public void start()
  • B、public void run()
  • C、public void int()
  • D、public static void main(Stringargs[])

正确答案:A

第5题:

下列有关main()方法的签名正确的是哪些?()

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

正确答案:A,C

第6题:

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

第7题:

public class foo {   public static void main (stringargs)   try {return;}   finally {system.out.printIn(“Finally”);}   }     What is the result?()  

  • A、 The program runs and prints nothing.
  • B、 The program runs and prints “Finally”
  • C、 The code compiles, but an exception is thrown at runtime.
  • D、 The code will not compile because the catch block is missing.

正确答案:B

第8题:

public class foo {   public static void main (Stringargs) {  String s;   system.out.printIn (“s=” + s);   }   }   What is the result?()

  • A、 The code compiles and “s=” is printed.
  • B、 The code compiles and “s=null” is printed.
  • C、 The code does not compile because string s is not initialized.
  • D、 The code does not compile because string s cannot be referenced.
  • E、 The code compiles, but a NullPointerException is thrown when toString is called.

正确答案:C

第9题:

下面关于Java应用程序中main方法的写法,合法的是()。

  • A、public static void main()
  • B、public static void main(Stringargs[])
  • C、public static int main(String[]arg)
  • D、public void main(Stringarg[])

正确答案:B

第10题:

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

更多相关问题