【单选题】Analyze the following code. public class Test { int x; public Test(String t) { System.out.println("Test"); } public static void main(String[] args) { Test test = null; System.out.println(test.x); } }
A.
The program has a compile error because x has not been initialized.
B.
The program has a compile error because test is not initialized.
C.
The program has a runtime NullPointerException because test is null while executing test.x
D.
The program has a compile error because you cannot create an object from the class that defines the object.
【简答题】下面的构造方法属于( ): public class Test { Test(){ } Test(String s){ } public static void main(String[] args) { Test t1=new Test(); Test t2=new Test(" 测试"); }}
【单选题】Analyze the following code. public class Test { int x; public Test(String t) { System.out.println("Test"); } public static void main(String[] args) { Test test = null; System.out.println(test.x); } }
A.
The program has a compile error because x has not been initialized.
B.
The program has a compile error because test is not initialized.
C.
The program has a runtime NullPointerException because test is null while executing test.x.
D.
The program has a compile error because you cannot create an object from the class that defines the object.
E.
The program has a compile error because Test does not have a default constructor.
【多选题】已有如下程序: class Test{ void Test(int i){System.out.println("I am an int");} void Test(String i){System.out.println("I am an String");} public static void main(String args[]){ Test t=new Test(); t.Test('y...