class Parent {
public static void show()
{
System.out.println("parent ");
}
}
class Child extends Parent {
public static void show()
{
System.out.println("child ");
}
public static void main(String[] args)
{
Child c=new Child();
c.show();
Parent pc=new Child();
pc.show();
}
}
static-----static possible
static-----nonstatic not possible
nonstatic--------static not possible
so it is not method overridding it is method hiding
public static void show()
{
System.out.println("parent ");
}
}
class Child extends Parent {
public static void show()
{
System.out.println("child ");
}
public static void main(String[] args)
{
Child c=new Child();
c.show();
Parent pc=new Child();
pc.show();
}
}
static-----static possible
static-----nonstatic not possible
nonstatic--------static not possible
so it is not method overridding it is method hiding
No comments:
Post a Comment