Note:Runtime polymorphism can't be achieved by data members.
Java Programming Language Class, Object and Methods in java (Article) Class, Object and Methods in java (Program)
1922Program:
class Parent { int age=70; } class ChildClass extends Parent{ int age=20; public static void main(String args[]){ Parent obj=new Child(); System.out.println(obj.age); // result will be 70 } }
Output:
70 Press any key to continue . . .
This Particular section is dedicated to Programs only. If you want learn more about Java Programming Language. Then you can visit below links to get more depth on this subject.