单项选择题
1.public classA{
2.public String doit(intx,inty){
3.return"a";
4.}
5.
6.public String doit(int...vals){
7.return"b";
8.}
9.}
And:
25.A a=new A();
26.System.out.println(a.doit(4,5));
What is the result?()
A.Line 26 prints "a" to System.out.
B.Line 26 prints "b" to System.out.
C.An exception is thrown at line 26 at runtime.
D.Compilation of class A will fail due to an error in line 6.
相关考题
-
单项选择题
A programmer needs to create a logging method that can accept an arbitrary number of arguments.Forexample,it may be called in these ways: logIt("log message 1"); logIt("log message 2”,”log message 3"); logIt("log message 4","log message 5","log message 6"); Which declaration satisfies this requirement()?
A.public void logIt(String*msgs)
B.public void logIt(String[]msgs)
C.public void logIt(String...msgs)
D.public voidl ogIt(Stringmsg1,Stringmsg2,Stringmsg3) -
多项选择题
10.publicclassBar{ 11.staticvoidfoo(int...x){ 12.//insertcodehere 13.} 14.} Which two code fragments,inserted independently at line1 2,will allow the class to compile()
A.foreach(x)System.out.println(z);
B.for(intz:x)System.out.println(z);
C.while(x.hasNext())System.out.println(x.next());
D.for(inti=0;i -
单项选择题
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].
