CMS专题

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

如果没有搜索结果,请直接 联系老师 获取答案。
如果没有搜索结果,请直接 联系老师 获取答案。
相似问题和答案

第1题:

Given:Which regular expression, inserted at line 12, correctly splits test into "Test A", "Test B", and "Test C"?()

A.String regex="";

B.String regex=" .";

C.String regex=".*";

D.String regex="\\s";

E.String regex="\\.\\s*";

F.String regex="\\w[\.]+";


参考答案:E

第2题:

Given:Andthefollowingfivefragments:publicstaticvoidmain(String...a){publicstaticvoidmain(String.*a){publicstaticvoidmain(String...a){publicstaticvoidmain(String[]...a){publicstaticvoidmain(String...[]a){Howmanyofthecodefragments,insertedindependentlyatline2,compile?()

A.0

B.1

C.2

D.3

E.4


参考答案: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题:

Given that c is a reference to a valid java.io.Console object, which two code fragments read a line of text from the console?()

  • A、String s = c.readLine();
  • B、char[ ] c = c.readLine();
  • C、String s = c.readConsole();
  • D、char[ ] c = c.readConsole();
  • E、String s = c.readLine("%s", "name ");
  • F、char[ ] c = c.readLine("%s", "name ");

正确答案:A,E

第5题:

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

第6题:

Given:String[]elements={"for","tea","too"};Stringfirst=(elements.length>0)?elements[0]:null;Whatistheresult?()

A.Compilationfails.

B.Anexceptionisthrownatruntime.

C.Thevariablefirstissettonull.

D.Thevariablefirstissettoelements[0].


参考答案:D

第7题:

floatf;Strings;现需要把float转化为String,正确的语句是()

  • A、s=String.valueOf(f);
  • B、f=Float.parseFloat(s);
  • C、s=f;
  • D、s=(String)f;

正确答案:A

第8题:

String[]elements={for”,tea”,too”};Stringfirst=(elements.length>0)?elements[0]null;Whatistheresult?()

A.Compilationfails.

B.Anexceptionisthrownatruntime.

C.Thevariablefirstissettonull.

D.Thevariablefirstissettoelements[0].


参考答案:D

第9题:

Given: 11.String test = "a1b2c3"; 12.String[] tokens = test.split("//d"); 13.for(String s: tokens) System.out.print(s + " "); What is the result?()

  • A、a b c
  • B、1 2 3
  • C、a1b2c3
  • D、a1 b2 c3

正确答案:A

第10题:

有声明语句:delegate void TimeDelegate(string s),则以下语句可以和委托TimeDelegate绑定的方法是()

  • A、 void f(){  }
  • B、 string f(){  }
  • C、 void f(string a){  }
  • D、 string f(string a){  }

正确答案:C

更多相关问题