【单选题】分析以下代码 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.
该程序有一个编译错误,因为test未初始化。
C.
该程序有一个编译错误,因为您不能从定义对象的类中创建对象。
D.
该程序有一个编译错误,因为Test没有默认的构造函数。
E.
该程序具有运行时NullPointerException,因为执行test.x时test为null。
【单选题】分析以下代码public class Test { public static void main(String[] args) { System.out.println(m(2)); } public static int m(int num) { return num; } public static void m(int num) { System.out.println(num); }}
A.
程序有编译错误,因为这两个方法m有相同的方法签名。
B.
该程序有编译错误,因为定义了第二个m方法,但是没有在主方法中调用。
【简答题】1997年4月19日,中国人民银行发布了《大额现金_____规定》。
【多选题】2005年1月19日,《有机产品国家标准》正式发布,并于2005年4月1日起正式实施,该标准共分为( )等部分。
【多选题】2005年1月19日,《有机产品国家标准》正式发布,并于2005年4月1日起正式实施,设标准共分为()等部分。
【单选题】分析以下代码 public class Test { public static void main(String[] args) { System.out.println(m(2)); } public static int m(int num) { return num; } public static void m(int num) { System.out.println(num); }...
A.
该程序有一个编译错误,因为两个方法m具有相同的签名。
B.
该程序有一个编译错误,因为定义了第二个m方法,但未在main方法中调用它。
【单选题】分析以下代码:public class A extends B {}class B { public B(String s) { }}
A.
程序有一个编译错误,因为A没有默认的构造函数。
B.
程序有一个编译错误,因为A的默认构造函数调用B的默认构造函数,而B没有默认构造函数。
C.
如果将构造函数 A(String s){} 添加到A 类中,则该程序可以通过编译。
D.
如果你将构造函数 A(String s) {super(s); } 添加到A 类中,则该程序可以通过编译。
【单选题】有如下代码: public class X { public X f() {return this;} } public class Y extends X { //method to add } 以下能添加到Y类的定义中的方法是( )
C.
private Y f() { return null;}
D.
public X f() { return new Y();}
【单选题】设有如下代码public class Test7{ static String a[] = new String[10]; public static void main(String arg[] ) { System.out.println(a[6]); }}以下哪个叙述为真?
【单选题】有以下代码: public class E { public static void main (String args[ ]) { int m=10,n=0; while(【代码】) { n++; } } } 用下列哪个代码替换程序标注的【代码】会导致编译错误?