In some cases, is-a relationships are used in the process of autoboxing.: TRUE..How ?? Please provide an example. Given Explanation : For instance, you can autobox an int to a Number (via an Integer).
actually this is related to overriding
in the subclass
you are writing the method which override the superclass methods
and overriding method rules say that
the return type should be same or the subclass of the return type This is not about boxing and unboxing
SCJP 6 [86%], OCPWCD [84%], OCEJPAD [83%]
If you find any post useful, click the "plus one" sign on the right
Hi Prasad, I think you are referring about covariant return types. I am looking for this "In some cases, is-a relationships are used in the process of autoboxing.: TRUE..How ?? Please provide an example, that would be really helpful. "
Then your query is simple
this is a sample program that can make you understand the concept
here we are returning an int value that is getting autoboxed into Integer
and Integer IS-A Number
so return type Number is also valid
this is called as Boxing and then Widening
hope this helps now
SCJP 6 [86%], OCPWCD [84%], OCEJPAD [83%]
If you find any post useful, click the "plus one" sign on the right