Compilation fails.
An exception is thrown at runtime.
The code executes normally and prints "sleep".
The code executes normally, but nothing is printed.
第1题:
public class foo { public static void main (stringargs) try {return;} finally {system.out.printIn(“Finally”);} } What is the result?()
第2题:
public class TestOne implements Runnable { public static void main (String[] args) throws Exception { Thread t = new Thread(new TestOne()); t.start(); System.out.print(”Started”); t.join(); System.out.print(”Complete”); } public void run() { for (int i= 0; i< 4; i++) { System.out.print(i); } } } What can be a result?()
第3题:
Given 1. public class Foo { 2. public static void main (String [] args) } 3. try { return;} 4. finally { Syste.out.printIn (“Finally”);} 5. } 6. } What is the result( )?
第4题:
Given: String[] elements = { "for", "tea", "too" }; String first = (elements.length > 0) ? elements[0] : null; What is the result?()
第5题:
Compilation fails.
An exception is thrown at runtime.
The code executes normally and prints “sleep”.
The code executes normally, but nothing is printed.
第6题:
Compilation fails.
An exception is thrown at runtime.
The code executes and prints "running".
The code executes and prints "runningrunning".
The code executes and prints "runningrunningrunning".
第7题:
Compilation of class A fails.
Line 28 prints the value 3 to System.out.
Line 28 prints the value 1 to System.out.
A runtime error occurs when line 25 executes.
Compilation fails because of an error on line 28.
第8题:
Compilation of class A fails.
Line 28 prints the value 3 to System.out.
Line 28 prints the value 1 to System.out.
Compilation fails because of an error on line 28.
A runtime error occurs when line 25 executes.
第9题:
Compilation fails.
An exception is thrown at runtime.
doStuff x = 6 main x = 6
doStuff x = 6 main x = 7
doStuff x = 7 main x = 6
第10题:
Compilation fails.
An exception is thrown at runtime.
The code executes normally and prints "bar".
The code executes normally, but nothing prints.
第11题:
The program runs and prints nothing.
The program runs and prints “Finally”.
The code comiles. But an exception is thrown at runtime.
The code will not compile because the catch block is missing.
第12题:
Hello
Hello World
Compilation fails.
Hello World 5
The code runs with no output.
An exception is thrown at runtime.
第13题:
public class foo { public static void main (string[]args) try {return;} finally {system.out.printIn(“Finally”);} } What is the result?()
第14题:
public class TestOne { public static void main (String[] args) throws Exception { Thread.sleep(3000); System.out.println(”sleep”); } } What is the result?()
第15题:
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?()
第16题:
Compilation fails.
An exception is thrown at runtime.
The code executes and prints “running”.
The code executes and prints “runningrunning”.
The code executes and prints “runningrunningrunning”.
第17题:
Compilation fails.
ClassC is displayed.
The code runs with no output.
An exception is thrown at runtime.
第18题:
Compilation fails.
An exception is thrown at runtime.
The code executes and prints “StartedComplete”.
The code executes and prints “StartedComplete0123”.
The code executes and prints “Started0l23Complete”.
第19题:
Compilation fails.
An exception is thrown at runtime.
The code executes normally and prints „foo”.
The code executes normally, but nothing is printed.
第20题:
Compilation fails.
An exception is thrown at runtime.
The code executes normally and prints “bar”.
The code executes normally, but nothing prints.
第21题:
The program runs and prints nothing.
The program runs and prints “Finally”
The code compiles, but an exception is thrown at runtime.
The code will not compile because the catch block is missing.
第22题:
The code runs with no output.
An exception is thrown at runtime.
Compilation fails because of an error in line 20.
Compilation fails because of an error in line 21.
Compilation fails because of an error in line 23.
Compilation fails because of an error in line 25.
第23题:
Class A
Compilation fails.
An exception is thrown at line 2.
An exception is thrown at line 6.
The code executes with no output.