Social Icons

Wednesday, 4 September 2013

Dynamic Method dispatch

class A
{


void show()
{
System.out.println("\n it is of a class");
}

}


class B extends A
{
void show()
{

System.out.println("\n it is of B class");
}


}




class C extends B
{
void show()
{

System.out.println("\n it is of C class");
}

}

class over
{
public static void main(String args[])
{
C c=new C();
A a =new A();
B b=new B();
A r;
r=a;
a.show();
r=b;
b.show();
r=c;
r.show();
}
}

No comments:

Post a Comment

 

Sample Text

Sample text

 
Just Programming Cse DriveReputation Management