p superob = new p ( );
Subob. i = 8;
Subob. j = 7;
Subob. a = 9;
Subob.showij ( );
Subob.showa ( );
System.out.println (“sum of i, j and a”);
Contents: I and j: 8 7
Sum of i, j and a: i + j +a: 24
Main use of inheritance in java is for overriding and code reusability.
When sub classes are identical of a super class this scenario is called method
It provides the characteristic called polymorphism in java.