PROGRAM:
A program to show simple
inheritance.
/**
* @Prof. Jayesh
* Here two classes are created each having main function
* A class calls the main() of another class
*/
public class Papa
{
void show()
{
System.out.println(“I am in class Papa”);
}
}
public class Child
extends Papa{
void
show()
{
System.out.println(“I am in child class”);
}
public static void
main(String args[])
{
Papa pa=new Papa();
pa.show();
Papa pp=new Child();
pp.show();
}
}
OUTPUT:
I
am in class Papa
I
am in child class