class Base
{
void show()
{
System.out.println("This is Base Show");
}
}
class Dynamic extends Base
{
void show()
{
System.out.println("This is Derived Show");
}
void disp()
{
System.out.println("This is Derived Disp");
}
public static void main(String []args)
{
Base b = new Dynamic();
b.show(); //storing reference of object of derived class in base class creates dynamic disp.
}
}
{
void show()
{
System.out.println("This is Base Show");
}
}
class Dynamic extends Base
{
void show()
{
System.out.println("This is Derived Show");
}
void disp()
{
System.out.println("This is Derived Disp");
}
public static void main(String []args)
{
Base b = new Dynamic();
b.show(); //storing reference of object of derived class in base class creates dynamic disp.
}
}
No comments:
Post a Comment