Correct Answer : D
The object I
of the class Integer
is created and the method string()
is called. Then, object t
of the class Integer2
is created and initially t.x
stores a default value of zero. Then when the method fix
is called with parameter t
and the value 42
is stored in x
variable of the object tt
which is same as t
. Since tt
is returned and the return value is assigned to t2
, both t2
and t
point to the same object. Hence the values of t.x
and t2.x
will be 42
. Atlast, the required values are printed.
Also note that, since the Integer
class is created here in the default package, it does not clash with the wrapper class java.lang.Integer
.
Hence, the answer is D.