aspose file tools*
The moose likes Beginning Java and the fly likes public Class variables and inheritance Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "public Class variables and inheritance" Watch "public Class variables and inheritance" New topic
Author

public Class variables and inheritance

Tejas Aryan
Greenhorn

Joined: Apr 12, 2009
Posts: 22
This is a very basic behavior and I am posting just to make that I understand this properly:



The reason the output : 9 is that class members are not overridden like methods and the value of variable is determined by the type of reference variable.. Please correct, if I am wrong or missing something. If someone can explain more clearly the please post..

Thanks,
Gaurav.
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

That is correct. Polymorphism applies only to instance methods and not to variables.


"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Tejas Aryan
Greenhorn

Joined: Apr 12, 2009
Posts: 22
In short:

variables in java are "early" binded.
methods are "late" binded.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: public Class variables and inheritance