class grand_parent
{
void gp()
{
System.out.println("I am grand parent");
}
}
//extends the properties of superclass grand_parent
class parent extends grand_parent
{
void p()
{
System.out.println("I am parent");
}
}
//extends the properties of superclass parent
class child extends parent
{
void c()
{
System.out.println("I am child");
}
}
public class Main
{
public static void main(String args[])
{
child c = new child();
// Accessing method of superclass with instance of subclass
c.c();
c.p();
c.gp();
}
}