Compilation fails.
An exception is thrown at runtime.
The variable first is set to null.
The variable first is set to elements[0].
第1题:
String[] elements = { “for”, “tea”, “too” }; String first = (elements.length > 0)? elements[0] null; What is the result?()
第2题:
public static void main(String[] args) { String str = “null‟; if (str == null) { System.out.println(”null”); } else (str.length() == 0) { System.out.println(”zero”); } else { System.out.println(”some”); } } What is the result?()
第3题:
public class Test { public static void main(String[] args) { String str = NULL; System.out.println(str); } } What is the result?()
第4题:
String[] elements={"for","tea","too"}; String first=(elements.length>0)?elements[0]null; What is the result?()
第5题:
public class TestOne { public static void main (String[] args) throws Exception { Thread.sleep(3000); System.out.println(”sleep”); } } What is the result?()
第6题:
Compilation fails.
An exception is thrown at runtime.
The variable first is set to null.
The variable first is set to elements[0].
第7题:
Compilation fails.
An exception is thrown at runtime.
The code executes normally and prints "sleep".
The code executes normally, but nothing is printed.
第8题:
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".
第9题:
An exception is thrown at runtime.
1
4
Compilation fails.
0
第10题:
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
第11题:
null
zero
some
Compilation fails.
An exception is thrown at runtime.
第12题:
Compilation fails.
An exception is thrown at runtime.
The variable first is set to null.
The variable first is set to elements[0].
第13题:
11. public enum Title { 12. MR(”Mr.”), MRS(”Mrs.”), MS(”Ms.”); 13. private final String title; 14. private Title(String t) { title = t; } 15. public String format(String last, String first) { 16. return title + “ “ + first + “ “ + last; 17. } 18. } 19. public static void main(String[] args) { 20. System.out.println(Title.MR.format(”Doe”, “John”)); 21. } What is the result?()
第14题:
Given: 11. String test = "This is a test"; 12. String[] tokens = test.split("/s"); 13. System.out.println(tokens.length); What is the result?()
第15题:
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?()
第16题:
public class Drink implements Comparable { public String name; public int compareTo(Object o) { return 0; } } and: Drink one = new Drink(); Drink two = new Drink(); one.name= “Coffee”; two.name= “Tea”; TreeSet set = new TreeSet(); set.add(one); set.add(two); A programmer iterates over the TreeSet and prints the name of each Drink object. What is the result?()
第17题:
Given: String[] elements = { "for", "tea", "too" }; String first = (elements.length > 0) ? elements[0] : null; What is the result?()
第18题:
Compilation fails.
An exception is thrown at runtime.
The code executes normally and prints “sleep”.
The code executes normally, but nothing is printed.
第19题:
Tea
Coffee
Coffee Tea
Compilation fails.
The code runs with no output.
An exception is thrown at runtime.
第20题:
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”.
第21题:
Compilation fails.
An exception is thrown at runtime.
The code executes normally and prints “bar”.
The code executes normally, but nothing prints.
第22题:
Compilation fails.
An exception is thrown at runtime.
The variable first is set to null.
The variable first is set to elements[0].
第23题:
Mr. John Doe
An exception is thrown at runtime.
Compilation fails because of an error in line 12.
Compilation fails because of an error in line 15.
Compilation fails because of an error in line 20.
第24题:
NULL
Compilation fails.
The code runs with no output.
An exception is thrown at runtime.