Hi,
when I compiled and run the following code I am getting output as "overriding in static2" followed by "in static1" but static methods can be overridden by a static method so in this code s1 is holding the object of static2 so it should call the method of static2 only but why it is calling the method of class static1 please can anybody help me...
class static1
{
protected static void method1()
{
System.out.println("in class static1");
}
}
public class static2 extends static1
{
protected static void method1()
{
System.out.println("overriding");
System.out.println("in static2");
}
public static void main(
String args[])
{
static2 s=new static2();
static1 s1=new static2(); //holding the object of static2
s.method1();
s1.method1(); //here it is calling the method of static1 ....
}
}
please help me..
Regards
Krishna