Base class Construtor!
Derived class Construtor!
b.value is : 1
derived version
b.getValue() : 2
Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
Thanks&Regards, Krishna.
SCJP1.4, SCWCD1.4, SCBCD 5.0
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]
Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
[QB]Looks like me missed one point here.
B b=new A();
b.prn();
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.
Thanks