Sunday 3 February 2013


Do Upcasting effects on Static methods?

Why It calls base class method when we declare method as static in base as well as in derive class and do upcasting.

class Base
{
static void show(){
System.out.println("Base class....");
}
}
class Derive extends Base
{
static void show(){
System.out.println("Drive class....");
}//method hidding.....
public static void main(String[] args) 
{
Base b= new Derive();
b.show(); 
}
}

No comments:

Post a Comment