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题:
String[] elements={"for","tea","too"}; String first=(elements.length>0)?elements[0]null; What is the result?()
第4题:
11. String test = “This is a test”; 12. String[] tokens = test.split(”/s”); 13. System.out.println(tokens.length); What is the result?()
第5题:
1. import java.util.*; 2. public class TestSet { 3. enum Example { ONE, TWO, THREE } 4. public static void main(String[] args) { 5. Collection coll = new ArrayList(); 6. coll.add(Example.THREE); 7. coll.add(Example.THREE); 8. coll.add(Example.THREE); 9. coll.add(Example.TWO); 10. coll.add(Example.TWO); 11. coll.add(Example.ONE); 12. Set set = new HashSet(coll); 13. } 14. } Which statement is true about the set variable on line 12?()
第6题:
Given: String[] elements = { "for", "tea", "too" }; String first = (elements.length > 0) ? elements[0] : null; What is the result?()
第7题:
Compilation fails.
An exception is thrown at runtime.
The variable first is set to null.
The variable first is set to elements[0].
第8题:
Compilation fails.
An exception is thrown at runtime.
The code executes normally and prints "sleep".
The code executes normally, but nothing is printed.
第9题:
Tea
Coffee
Coffee Tea
Compilation fails.
The code runs with no output.
An exception is thrown at runtime.
第10题:
Compilation fails.
An exception is thrown at runtime.
The code executes normally and prints “bar”.
The code executes normally, but nothing prints.
第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题:
public class Test { public static void main(String[] args) { String str = NULL; System.out.println(str); } } What is the result?()
第15题:
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?()
第16题:
public class TestOne { public static void main (String[] args) throws Exception { Thread.sleep(3000); System.out.println(”sleep”); } } What is the result?()
第17题:
String a = null; a.concat(“abc”); a.concat(“def”); System.out.println(a); What is the result?()
第18题:
The set variable contains all six elements from the coll collection, and the order is guaranteed to be preserved.
The set variable contains only three elements from the coll collection, and the order is guaranteed to be preserved.
The set variable contains all six elements from the coil collection, but the order is NOT guaranteed to be preserved.
The set variable contains only three elements from the coil collection, but the order is NOT guaranteed to be preserved.
第19题:
Compilation fails.
An exception is thrown at runtime.
The code executes normally and prints “sleep”.
The code executes normally, but nothing is printed.
第20题:
abc
null
abcdef
Compilation fails.
The code runs with no output.
An exception is thrown at runtime.
第21题:
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".
第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.