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


相似考题
参考答案和解析
正确答案: B
解析: 暂无解析
更多“单选题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].”相关问题
  • 第1题:

    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].

    正确答案:D

  • 第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?()

    • A、 null
    • B、 zero
    • C、 some
    • D、 Compilation fails.
    • E、 An exception is thrown at runtime.

    正确答案:D

  • 第3题:

    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].

    正确答案:D

  • 第4题:

    11. String test = “This is a test”;  12. String[] tokens = test.split(”/s”);  13. System.out.println(tokens.length);  What is the result?() 

    • A、 0
    • B、 1
    • C、 4
    • D、 Compilation fails.
    • E、 An exception is thrown at runtime.

    正确答案:D

  • 第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?() 

    • 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.

    正确答案:D

  • 第6题:

    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].

    正确答案:D

  • 第7题:

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


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

  • 第8题:

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


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

  • 第9题:

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

     Tea

    B

     Coffee

    C

     Coffee Tea

    D

     Compilation fails.

    E

     The code runs with no output.

    F

     An exception is thrown at runtime.


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

  • 第10题:

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


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

  • 第11题:

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

     null

    B

     zero

    C

     some

    D

     Compilation fails.

    E

     An exception is thrown at runtime.


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

  • 第12题:

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


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

  • 第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?() 

    • A、 Mr. John Doe
    • B、 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.

    正确答案:A

  • 第14题:

    public class Test {  public static void main(String[] args) {  String str = NULL;  System.out.println(str);  }  }   What is the result?()  

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

    正确答案:B

  • 第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?() 

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

    正确答案:B

  • 第16题:

    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.

    正确答案:C

  • 第17题:

    String a = null;  a.concat(“abc”);  a.concat(“def”);  System.out.println(a);   What is the result?()  

    • A、 abc
    • B、 null
    • C、 abcdef
    • D、 Compilation fails.
    • E、 The code runs with no output.
    • F、 An exception is thrown at runtime.

    正确答案:F

  • 第18题:

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


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

  • 第19题:

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


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

  • 第20题:

    单选题
    String a = null;  a.concat(“abc”);  a.concat(“def”);  System.out.println(a);   What is the result?()
    A

     abc

    B

     null

    C

     abcdef

    D

     Compilation fails.

    E

     The code runs with no output.

    F

     An exception is thrown at runtime.


    正确答案: D
    解析: Exception in thread "main" java.lang.NullPointerException at X.main(X.java:12) 

  • 第21题:

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


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

  • 第22题:

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


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

  • 第23题:

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

    B

     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.


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

  • 第24题:

    单选题
    public class Test {  public static void main(String[] args) {  String str = NULL;  System.out.println(str);  }  }   What is the result?()
    A

     NULL

    B

     Compilation fails.

    C

     The code runs with no output.

    D

     An exception is thrown at runtime.


    正确答案: C
    解析: NULL should be "null".