单选题public class Foo {  public void main (String [] args)   {  system.out.printIn(“Hello World.”); } }  What is the result?()AAn exception is thrown.BThe code does no compile.C“Hello World.” Is printed to the terminal.DThe program exits without printing an

题目
单选题
public class Foo {  public void main (String [] args)   {  system.out.printIn(“Hello World.”); } }  What is the result?()
A

 An exception is thrown.

B

 The code does no compile.

C

 “Hello World.” Is printed to the terminal.

D

 The program exits without printing anything.


相似考题
参考答案和解析
正确答案: A
解析: 暂无解析
更多“单选题public class Foo {  public void main (String [] args)   {  system.out.printIn(“Hello World.”); } }  What is the result?()A  An exception is thrown.B  The code does no compile.C  “Hello World.” Is printed to the terminal.D  The program exits without pri”相关问题
  • 第1题:

    public class Foo {  public void main( String[] args ) {  System.out.println( “Hello” + args[0] );  }  }   What is the result if this code is executed with the command line?()

    • A、 Hello
    • B、 Hello Foo
    • C、 Hello world
    • D、 Compilation fails.
    • E、 The code does not run.

    正确答案:E

  • 第2题:

    class A {  public A() {  System.out.println(“hello from a”);  }  }  class B extends A {  public B () {  System.out.println(“hello from b”);  super();  }  }  public class Test {  public static void main(String args[]) {  A a = new B();  }  }   What is the result when main is executed?()  

    • A、 Compilation fails.
    • B、 hello from a
    • C、 hello from b
    • D、 hello from b hello from a
    • E、 hello from a hello from b

    正确答案:A

  • 第3题:

    public class foo {  public static void main (String[]args) {  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

  • 第4题:

     public class X {   public static void main (String[]args)   {   string s = new string (“Hello”);   modify(s);   System.out.printIn(s);   }   public static void modify (String s)  {   s += “world!”;      }   }      What is the result?()    

    • A、 The program runs and prints “Hello”
    • B、 An error causes compilation to fail.
    • C、 The program runs and prints “Hello world!”
    • D、 The program runs but aborts with an exception.

    正确答案:A

  • 第5题:

    public class X {   public static void main (Stringargs) {   string s = new string (“Hello”);   modify(s);   System.out.printIn(s);   }   public static void modify (String s) {   s += “world!”;   }   }   What is the result?() 

    • A、The program runs and prints “Hello”
    • B、An error causes compilation to fail.
    • C、The program runs and prints “Hello world!”
    • D、The program runs but aborts with an exception.

    正确答案:A

  • 第6题:

    public class Threads4 {  public static void main (String[] args) {  new Threads4().go();  }  public void go() {  Runnable r = new Runnable() { public void run() {  System.out.print(”foo”);  }  };  Thread t = new Thread(r);  t.start();  t.start();  }  }  What is the result?() 

    • A、 Compilation fails.
    • B、 An exception is thrown at runtime.
    • C、 The code executes normally and prints „foo”.
    • D、 The code executes normally, but nothing is printed.

    正确答案:B

  • 第7题:

    单选题
    public class Test {   public static void main (String args) {   class Foo {   public int i = 3;  }   Object o = (Object) new Foo();   Foo foo = (Foo)o;   System.out.printIn(foo. i);  }   }   What is the result?()
    A

     Compilation will fail.

    B

     Compilation will succeed and the program will print “3”

    C

     Compilation will succeed but the program will throw a ClassCastException at line 6.

    D

     Compilation will succeed but the program will throw a ClassCastException at line 7.


    正确答案: D
    解析: 暂无解析

  • 第8题:

    单选题
    public class Foo {   public void main (String args) {   system.out.printIn(“Hello World.”);   }   }   What is the result? ()
    A

     An exception is thrown.

    B

     The code does no compile.

    C

     “Hello World.” Is printed to the terminal.

    D

     The program exits without printing anything.


    正确答案: A
    解析: 暂无解析

  • 第9题:

    单选题
    public class X {   public static void main (String[]args)   {   string s = new string (“Hello”);   modify(s);   System.out.printIn(s);   }   public static void modify (String s)  {   s += “world!”;      }   }      What is the result?()
    A

     The program runs and prints “Hello”

    B

     An error causes compilation to fail.

    C

     The program runs and prints “Hello world!”

    D

     The program runs but aborts with an exception.


    正确答案: B
    解析: 暂无解析

  • 第10题:

    单选题
    2. public class Foo implements Runnable (  3. public void run (Thread t) {  4. system.out.printIn(“Running.”);  5. }  6. public static void main (String[] args)  {  7. new thread (new Foo()).start(); 8. )  9. )   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
    解析: 暂无解析

  • 第11题:

    单选题
    public class foo {  public static void main (string[]args)  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.


    正确答案: D
    解析: 暂无解析

  • 第12题:

    单选题
    public class Foo {  public void main( String[] args ) {  System.out.println( “Hello” + args[0] );  }  }   What is the result if this code is executed with the command line?()
    A

     Hello

    B

     Hello Foo

    C

     Hello world

    D

     Compilation fails.

    E

     The code does not run.


    正确答案: E
    解析: 暂无解析

  • 第13题:

    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

  • 第14题:

    public class foo {  public static void main (string[]args)  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

  • 第15题:

    public class foo {  static String s;  public static void main (String[]args) {  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.

    正确答案:B

  • 第16题:

    public class Foo {  public static void main(String[] args) {  try {  return;  } finally {  System.out.println( “Finally” );  }  }  }  What is the result?()

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

    正确答案:A

  • 第17题:

    2. public class Foo implements Runnable (  3. public void run (Thread t) {  4. system.out.printIn(“Running.”);  5. }  6. public static void main (String[] args)  {  7. new thread (new Foo()).start(); 8. )  9. )   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

  • 第18题:

    import java.io.IOException;  public class ExceptionTest(  public static void main (String[]args)  try (  methodA();  ) catch (IOException e)  (  system.out.printIn(“Caught IOException”);  ) catch (Exception e)   (  system.out.printIn(“Caught Exception”);  )  )  public void methodA ()   {  throw new IOException ();  }   What is the result?() 

    • A、 The code will not compile.
    • B、 The output is caught exception.
    • C、 The output is caught IOException.
    • D、 The program executes normally without printing a message.

    正确答案:A

  • 第19题:

    单选题
    public class X {   public static void main (Stringargs) {   string s = new string (“Hello”);   modify(s);   System.out.printIn(s);   }   public static void modify (String s) {   s += “world!”;   }   }   What is the result?()
    A

    The program runs and prints “Hello”

    B

    An error causes compilation to fail.

    C

    The program runs and prints “Hello world!”

    D

    The program runs but aborts with an exception.


    正确答案: D
    解析: 暂无解析

  • 第20题:

    单选题
    import java.io.IOException;  public class ExceptionTest(  public static void main (String[]args)  try (  methodA();  ) catch (IOException e)  (  system.out.printIn(“Caught IOException”);  ) catch (Exception e)   (  system.out.printIn(“Caught Exception”);  )  )  public void methodA ()   {  throw new IOException ();  }   What is the result?()
    A

     The code will not compile.

    B

     The output is caught exception.

    C

     The output is caught IOException.

    D

     The program executes normally without printing a message.


    正确答案: D
    解析: 暂无解析

  • 第21题:

    单选题
    public class foo {  public static void main (String[]args) {  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.


    正确答案: A
    解析: 暂无解析

  • 第22题:

    单选题
    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.


    正确答案: B
    解析: 暂无解析

  • 第23题:

    单选题
    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.


    正确答案: E
    解析: 暂无解析

  • 第24题:

    单选题
    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”


    正确答案: A
    解析: 暂无解析