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 are same");
22: else
23: System.out.println("objects are different");
24: }
25: }
a) compilation error at line 20. equals() method was not defined.
b) compiles fine, runtime exception at line 20
c) prints "objects are same"
d) prints "objects are different"
My answer is c. But the given answer is d, why is it...? Can somebody explain me this...?
Thanks