Search This Blog

15 June, 2011

Simple Java program related to inheritance - part 3

class aaa
{
public void sam()
{
System.out.println("Hello");
}
}
class bbb extends aaa
{
public void tom()
{
System.out.println("Hi");
}
}
class psp
{
public static void main(String gg[])
{
aaa p1;
p1=new aaa();
p1.sam();
p1.tom();     // Incorrect


bbb p2;
p2=new bbb();
p2.sam();
p2.tom();


aaa p3;
p3=new bbb();
p3.sam();
p3.tom();         // Incorrect


bbb p4;
p4=new aaa(); // Incorrect
}
}


-----------------------------------------------------------------

No comments:

Post a Comment

Meetme@