itgle.com

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

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


相似考题
更多“单选题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 t”相关问题
  • 第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题:

    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

  • 第4题:

    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

  • 第5题:

    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

  • 第6题:

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

    单选题
    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
    解析: 暂无解析

  • 第8题:

    单选题
    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
    解析: 暂无解析

  • 第9题:

    单选题
    Given:   11. String test = "This is a test";   12. String[] tokens = test.split("/s");   13. System.out.println(tokens.length);   What is the result?()
    A

     An exception is thrown at runtime.

    B

     1

    C

     4

    D

     Compilation fails.

    E

     0


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

  • 第10题:

    单选题
    Given: What is the result?()
    A

    Compilation fails.

    B

    An exception is thrown at runtime.

    C

    doStuff x = 6 main x = 6

    D

    doStuff x = 6 main x = 7

    E

    doStuff x = 7 main x = 6


    正确答案: 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题:

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

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

    正确答案:D

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

    • A、 Compilation fails.
    • B、 An exception is thrown at runtime.
    • C、 The code executes and prints “StartedComplete”.
    • D、 The code executes and prints “StartedComplete0123”.
    • E、 The code executes and prints “Started0l23Complete”.

    正确答案:E

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

    • 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

  • 第17题:

    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

  • 第18题:

    单选题
    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
    解析: 暂无解析

  • 第19题:

    单选题
    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
    解析: 暂无解析

  • 第20题:

    单选题
    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?()
    A

     Compilation fails.

    B

     An exception is thrown at runtime.

    C

     The code executes and prints “StartedComplete”.

    D

     The code executes and prints “StartedComplete0123”.

    E

     The code executes and prints “Started0l23Complete”.


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

  • 第21题:

    单选题
    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
    解析: 暂无解析

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