06-04-2011, 01:17 PM
Code:
class A
{
void display()
{
System.out.println("Inside A");
}
}
class B extends A
{
void display()
{
System.out.println("Inside B");
}
}
class C extends B
{
void display()
{
System.out.println("Inside C");
}
}
class OverrideDemo
{
public static void main(String arg[])
{
A a=new A();
B b=new B();
C c=new C();
A r;
r=a;
r.display();
r=b;
r.display();
r=c;
r.display();
}
}
OUTPUT
E:\ 5BCA-B\lijo\java >java OverrideDemo
Inside A
Inside B
Inside C