public class Recipe
{
public static void main (String [] args)
{
out.println( Grandma.name() );
out.println( Mom.name() );
out.println( Grandma.age );
out.println( Mom.age );
Grandma grandma = new Grandma();
Mom mom = new Mom();
Grandma confuser = new Mom();
out.println( grandma.name() );
out.println( mom.name() );
out.println( confuser.name() );
out.println( grandma.age );
out.println( mom.age );
out.println( confuser.age );
out.println( grandma.recipe() );
out.println( mom.recipe() );
out.println( confuser.recipe() );
out.println( grandma.cups );
out.println( mom.cups );
out.println( confuser.cups );
out.println( ((Grandma)mom).recipe() );
out.println( ((Grandma)mom).cups );
out.println( ((Mom)confuser).recipe() );
out.println( ((Mom)confuser).cups );
out.println( grandma.getCups() );
out.println(mom.getCups() );
out.println( confuser.getCups() );
out.println( ((Grandma)mom).getCups() );
out.println( ((Mom)confuser).getCups() );
}
}
class Grandma
{
public static String name()
{
return( "Bessie" );
}
public static int age = 70;
String recipe()
{
return( "light a fire,..." );
}
public int cups = 20;
public int getCups()
{
return cups;
}
}
class Mom extends Grandma
{
public static String name()
{
return( "Rhonda" );
}
public static int age = 30;
public String recipe()
{
return( "Open a can ..." );
}
public int cups = 1;
}