Java Reference
In-Depth Information
Inheritance
Inheritance is a super class from which all the classes are inherited and which does inheriting
from a super class is called the sub class.
Basic program of inheritance
Class x
{
int i, j;
void show I j ( )
{
System.out.println (“i and j:” + i + ““+ j );
}
}
Class y extends x
Int a; {
System.out.println (“a: “+ a );
}
Void sum ( )
{
System.out.println (“i + j + a: “+ (i + j + a) );
}
}
Class simpinheritance
{
Public static void main (string args [ ])
{
q Superob = new q ( );
Search WWH ::




Custom Search