未分类 · 2025年11月21日

以下程序的输出为? 1: class MyClass 2: { 3: static int maxElements; 4: 5: MyClass(int maxElements) 6: { 7: this.maxElements = maxElements; 8: } 9: 10: } 11: 12: public class Q19 13: { 14: public static void main(String[] args) 15: { 16: 17: MyClass a = new MyClass(100); 18: MyClass b = new MyClass(100); 19: 20: if(a.equals(b)) 21: System.out.println(“Objects have the same A.在第20行出错. equals()方法未定义. B.编译通过,在运行时20行出现异常 C.输出 “Objects have different D.输出 “Objects have the same A.不能在构造方法中调用super B.构造方法的第一条语句 C.任何地方 D.构造方法的最后一条语句

以下程序的输出为? 1: class MyClass 2: { 3: static int maxElements; 4: 5: MyClass(int maxElements) 6: { 7: this.maxElements = maxElements; 8: } 9: 10: } 11: 12: public class Q19 13: { 14: public static void main(String[] args) 15: { 16: 17: MyClass a = new MyClass(100); 18: MyClass b = new MyClass(100); 19: 20: if(a.equals(b)) 21: System.out.println(“Objects have the same A.在第20行出错. equals()方法未定义. B.编译通过,在运行时20行出现异常 C.输出 “Objects have different D.输出 “Objects have the same A.不能在构造方法中调用super B.构造方法的第一条语句 C.任何地方 D.构造方法的最后一条语句

正确答案:C