aspose file tools*
The moose likes Beginning Java and the fly likes Inheritance Doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Inheritance Doubt" Watch "Inheritance Doubt" New topic
Author

Inheritance Doubt

Vikas Kapoor
Ranch Hand

Joined: Aug 16, 2007
Posts: 1374

Why there is no conflict between declaration of variable i in class Two with the one declared in class three?

I know there is nothing like variable overriding. If I declare i in subclass then it supercede the one declared in superclass.
[ December 30, 2008: Message edited by: Vishal Pandya ]
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

This is another one of those questions where the answer is "because that's how they designed it." The important thing to realize is that the variable in class three hides or shadows the one in class Two. They're two separate variables, and an instance of class three contains two different int variables named "i". For example,



[Jess in Action][AskingGoodQuestions]
Vikas Kapoor
Ranch Hand

Joined: Aug 16, 2007
Posts: 1374
Thanks EFH
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Inheritance Doubt