单选题String[] elements={"for","tea","too"}; String first=(elements.length0)?elements[0]null; What is the result?()ACompilation fails.BAn exception is thrown at runtime.CThe variable first is set to null.DThe variable first is set to elements[0].

单选题
String[] elements={"for","tea","too"}; String first=(elements.length>0)?elements[0]null; What is the result?()
A

Compilation fails.

B

An exception is thrown at runtime.

C

The variable first is set to null.

D

The variable first is set to elements[0].


参考解析

解析: 暂无解析

相关考题:

String[] elements={for,tea,too};String first=(elements.length0)?elements[0]null;What is the result?() A.Compilation fails.B.An exception is thrown at runtime.C.The variable first is set to null.D.The variable first is set to elements[0].

String[]elements={for”,tea”,too”};Stringfirst=(elements.length0)?elements[0]null;Whatistheresult?() A.Compilationfails.B.Anexceptionisthrownatruntime.C.Thevariablefirstissettonull.D.Thevariablefirstissettoelements[0].

Given:String[]elements={for,tea,too};Stringfirst=(elements.length0)?elements[0]:null;Whatistheresult?() A.Compilationfails.B.Anexceptionisthrownatruntime.C.Thevariablefirstissettonull.D.Thevariablefirstissettoelements[0].

public class Threads5 {  public static void main (String[] args) {  new Thread(new Runnable() {  public void run() {  System.out.print(”bar”);  } }).start();  }  }  What is the result?() A、 Compilation fails.B、 An exception is thrown at runtime.C、 The code executes normally and prints “bar”.D、 The code executes normally, but nothing prints.

String[] elements = { “for”, “tea”, “too” };  String first = (elements.length  0)? elements[0] null;  What is the result?()A、 Compilation fails.B、 An exception is thrown at runtime.C、 The variable first is set to null.D、 The variable first is set to elements[0].

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?() A、 Mr. John DoeB、 An exception is thrown at runtime.C、 Compilation fails because of an error in line 12.D、 Compilation fails because of an error in line 15.E、 Compilation fails because of an error in line 20.

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?()A、 nullB、 zeroC、 someD、 Compilation fails.E、 An exception is thrown at runtime.

public class Test {  public static void main(String[] args) {  String str = NULL;  System.out.println(str);  }  }   What is the result?()  A、 NULLB、 Compilation fails.C、 The code runs with no output.D、 An exception is thrown at runtime.

String[] elements={"for","tea","too"}; String first=(elements.length0)?elements[0]null; What is the result?()A、Compilation fails.B、An exception is thrown at runtime.C、The variable first is set to null.D、The variable first is set to elements[0].

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?() A、 TeaB、 CoffeeC、 Coffee TeaD、 Compilation fails.E、 The code runs with no output.F、 An exception is thrown at runtime.

11. String test = “This is a test”;  12. String[] tokens = test.split(”/s”);  13. System.out.println(tokens.length);  What is the result?() A、 0B、 1C、 4D、 Compilation fails.E、 An exception is thrown at runtime.

public class TestOne {  public static void main (String[] args) throws Exception {  Thread.sleep(3000);  System.out.println(”sleep”);  }  }  What is the result?() A、 Compilation fails.B、 An exception is thrown at runtime.C、 The code executes normally and prints “sleep”.D、 The code executes normally, but nothing is printed.

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?() A、 The set variable contains all six elements from the coll collection, and the order is guaranteed to be preserved.B、 The set variable contains only three elements from the coll collection, and the order is guaranteed to be preserved.C、 The set variable contains all six elements from the coil collection, but the order is NOT guaranteed to be preserved.D、 The set variable contains only three elements from the coil collection, but the order is NOT guaranteed to be preserved.

String a = null;  a.concat(“abc”);  a.concat(“def”);  System.out.println(a);   What is the result?()  A、 abcB、 nullC、 abcdefD、 Compilation fails.E、 The code runs with no output.F、 An exception is thrown at runtime.

Given: String[] elements = { "for", "tea", "too" }; String first = (elements.length  0) ? elements[0] : null; What is the result?()A、Compilation fails.B、An exception is thrown at runtime.C、The variable first is set to null.D、The variable first is set to elements[0].

单选题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?()A The set variable contains all six elements from the coll collection, and the order is guaranteed to be preserved.B The set variable contains only three elements from the coll collection, and the order is guaranteed to be preserved.C The set variable contains all six elements from the coil collection, but the order is NOT guaranteed to be preserved.D The set variable contains only three elements from the coil collection, but the order is NOT guaranteed to be preserved.

单选题String[] elements = { “for”, “tea”, “too” };  String first = (elements.length  0)? elements[0] null;  What is the result?()A Compilation fails.B An exception is thrown at runtime.C The variable first is set to null.D The variable first is set to elements[0].

单选题public class TestOne {  public static void main (String[] args) throws Exception {  Thread.sleep(3000);  System.out.println(”sleep”);  }  }  What is the result?()A Compilation fails.B An exception is thrown at runtime.C The code executes normally and prints “sleep”.D The code executes normally, but nothing is printed.

单选题Given: What is the result?()A Compilation fails.B An exception is thrown at runtime.C The code executes normally and prints "sleep".D The code executes normally, but nothing is printed.

单选题String a = null;  a.concat(“abc”);  a.concat(“def”);  System.out.println(a);   What is the result?()A abcB nullC abcdefD Compilation fails.E The code runs with no output.F An exception is thrown at runtime.

单选题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?()A TeaB CoffeeC Coffee TeaD Compilation fails.E The code runs with no output.F An exception is thrown at runtime.

单选题Given: What is the result?()A Compilation fails.B An exception is thrown at runtime.C The code executes and prints "running".D The code executes and prints "runningrunning".E The code executes and prints "runningrunningrunning".

单选题public class Threads5 {  public static void main (String[] args) {  new Thread(new Runnable() {  public void run() {  System.out.print(”bar”);  } }).start();  }  }  What is the result?()A Compilation fails.B An exception is thrown at runtime.C The code executes normally and prints “bar”.D The code executes normally, but nothing prints.

单选题Given: String[] elements = { "for", "tea", "too" }; String first = (elements.length  0) ? elements[0] : null; What is the result?()ACompilation fails.BAn exception is thrown at runtime.CThe variable first is set to null.DThe variable first is set to elements[0].

单选题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?()A nullB zeroC someD Compilation fails.E An exception is thrown at runtime.

单选题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?()A Mr. John DoeB An exception is thrown at runtime.C Compilation fails because of an error in line 12.D Compilation fails because of an error in line 15.E Compilation fails because of an error in line 20.

单选题String[] elements={"for","tea","too"}; String first=(elements.length0)?elements[0]null; What is the result?()ACompilation fails.BAn exception is thrown at runtime.CThe variable first is set to null.DThe variable first is set to elements[0].

单选题public class Test {  public static void main(String[] args) {  String str = NULL;  System.out.println(str);  }  }   What is the result?()A NULLB Compilation fails.C The code runs with no output.D An exception is thrown at runtime.