Consider the following situation:

a. A class A has Object as its superclass and a class B has class A as its superclass.

b. Class A has a no argument constructor.

c. Class B has an integer field x and a constructor with an integer argument for initializing x.

d. A does not override the equals method inherited from Object.

e. Class B overrides equals so that two objects of class B are considered equal if their field x has the same value in both objects:

f. We test these classes with the following code:

and “false” gets printed. The reason for overriding equals in class B was to allow two objects of class B to be equal if their fields x had the same value, but the test code shows that something is wrong. What is wrong? What is the fix?



Doing a similar assignment? Save your time and hire our Genuine Essay Writers to do your task. Get 15% Discount on your 1st order. Use code: FREE15