aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Variable hiding Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Variable hiding" Watch "Variable hiding" New topic
Author

Variable hiding

lu v thuan
Ranch Hand

Joined: Oct 25, 2001
Posts: 32
Hi Friends

I think the result is :15 , 15
Am i wrong, if so pls make it clear to me?
Thank in advanced
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
The answer is 15 and 5.
The cast you have made here ((A)bobj))is equivalent to assigning a base class reference to a superclass type. Hence the i in the superclass gets invoked. Do take a look at this modified code and run it...it might help.

HTH
Shyam
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Variable hiding