编译并运行以下代码将发生什么?( ) class MyClass { int x;
MyClass(int i) { x = i; }
public static void main(String args[]) {
MyClass m1 = new MyClass(100);
MyClass m2 = new MyClass(100);
if (m1.equals(m2)) {
System.out.println("Both are equal"); }
else { System.out.println("Both are not equal"); }
}
} A. 代码编译时报出错误提示信息“equals() 方法未定义” B. 编译通过,抛出运行期异常. C. 输出Both are equal. D. 输出Both are not equal
|
|