Wednesday, 2 April 2014

OverriddingDemo

public class Parent {
public void show(int a)
{
System.out.println("parent class method no return type"+a);
}
public int disp()
{
System.out.println("parent class disp method type");
return 0;
}

}

class Child extends Parent {
public void show(int a)
{
System.out.println("child no return type"+a);
}
public static void main(String[] args)
{
Child c=new Child();
c.show(2);
Parent pc=new Child();
pc.show(3);
Parent p=new Parent();
p.disp();


}

}

No comments:

Post a Comment