Base class Construtor!
Derived class Construtor!
b.value is : 1
b.getValue() : 2
Originally posted by Gitesh R:
[QB]Ok 2 points from my side,
1. To summarize, which overridden method to call (in other words, from which class in the inheritance tree) is decided at runtime based on object type, but which overloaded version of the method to call is based on the reference type passed at compile time.
2. Object type determines which overridden method is used at runtime and Reference type determines which overloaded method will be used at compile time.
[QB]Looks like me missed one point here.
B b=new A();
By any chance method prn() is static then it will call prn() from base class./QUOTE]
Can you elaborate what do you want to say?
making static prn() in derived class?
by the by static method cannot be overridden.