public class foo {
public static void main (Stringargs) {
String s;
system.out.printIn (“s=” + s);
}
}
What is the result?()
A. The code compiles and “s=” is printed.
B. The code compiles and “s=null” is printed.
C. The code does not compile because string s is not initialized.
D. The code does not compile because string s cannot be referenced.
E. The code compiles, but a NullPointerException is thrown when toString is called.
您可能感兴趣的试卷
你可能感兴趣的试题
int index = 1;
int foo[] = new int [3];
int bar = foo [index]
int baz = bar + index;
A.整型变量 baz 的值为 0
B.整型变量baz 的值为 1
C.整型变量 baz 的值为 2
D.执行错误
public class test(
public static void main(stringargs){
string foo = args [1];
string foo = args ;
string foo = args ;
}
)
And command line invocation: Java Test red green blue What is the result? ()
A. Baz has the value of “”
B. Baz has the value of null
C. Baz has the value of “red”
D. Baz has the value of “blue”
E. Bax has the value of “green”
F. The program throws an exception.
int index = 1;
boolean test = new Boolean;
boolean foo= test [index];
What is the result?()
A. Foo has the value of 0.
B. Foo has the value of null.
C. Foo has the value of true.
D. Foo has the value of false.
E. An exception is thrown.
F. The code will not compile.
A. Float foo = -1;
B. Float foo = 1.0;
C. Float foo = 42e1;
D. Float foo = 2.02f;
E. Float foo = 3.03d;
F. Float foo = 0x0123;
A. Run
B. Import
C. Default
D. Implement
//point X
public class foo (
public static void main (Stringargs) throws Exception {
printWriter out = new PrintWriter (new )
java.io.outputStreamWriter (System.out), true;
out.printIn(“Hello”);
}
)
Which statement at PointX on line 1 allows this code to compile and run?()
A. Import java.io.PrintWriter;
B. Include java.io.PrintWriter;
C. Import java.io.OutputStreamWriter;
D. Include java.io.OutputStreamWriter;
E. No statement is needed.
interface foo {
int k = 0;
}
public class test implements Foo (
public static void main(String args) (
int i;
Test test = new test ();
i= test.k;
i= Test.k;
i= Foo.k;
)
)
What is the result? ()
A. Compilation succeeds.
B. An error at line 2 causes compilation to fail.
C. An error at line 9 causes compilation to fail.
D. An error at line 10 causes compilation to fail.
E. An error at line 11 causes compilation to fail.
public class enclosingone (
public class insideone{}
)
public class inertest(
public static void main (stringargs)(
enclosingone eo= new enclosingone ();
//insert code here
)
)
Which statement at line 7 constructs an instance of the inner class?()
A. InsideOnew ei= eo.new InsideOn();
B. Eo.InsideOne ei = eo.new InsideOne();
C. InsideOne ei = EnclosingOne.new InsideOne();
D. EnclosingOne.InsideOne ei = eo.new InsideOne();
package foo;
public class Outer (
public static class Inner (
)
)
Which statement is true?()
A. An instance of the Inner class can be constructed with “new Outer.Inner()”
B. An instance of the inner class cannot be constructed outside of package foo.
C. An instance of the inner class can only be constructed from within the outer class.
D. From within the package bar, an instance of the inner class can be constructed with “new inner()”
A. An anonymous inner class may be declared as final.
B. An anonymous inner class can be declared as private.
C. An anonymous inner class can implement multiple interfaces.
D. An anonymous inner class can access final variables in any enclosing scope.
E. Construction of an instance of a static inner class requires an instance of the enclosing outer class.
![](https://static.ppkao.com/ppmg/img/appqrcode.png)
最新试题
Which statement is true?()
Which two of statements are true?()
What is the result?()
A programmer is developing a class Key, that will be used as a key in a standard java.util.HashMap. Which two methods should be overridden to assure that Key works correctly as a key?()
Which three changes should be made to adapt this class to be used safely by multiple threads?()
What is the result?()
What is the result?()
Which statement is true?()
What is the result?()
Which statement is true about the set variable on line 12?()