Hi All,
Please have a look at the following code :
public class SuperClass {
public static void method() {
System.out.println("SuperClass method");
}
}
class SubClass extends SuperClass {
public static void main(String args[]) {
SubClass subClass = new SubClass();
subClass.method();
}
}
The above code prints SuperClass method.
How it is working. As most of the books say, that inheritance and overriding does not apply to static methods. So the method was not inherited in SubClass, so how this code is working.
Waiting for a detailed reply.
Thanks and Regards
Please have a look at the following code :
public class SuperClass {
public static void method() {
System.out.println("SuperClass method");
}
}
class SubClass extends SuperClass {
public static void main(String args[]) {
SubClass subClass = new SubClass();
subClass.method();
}
}
The above code prints SuperClass method.
How it is working. As most of the books say, that inheritance and overriding does not apply to static methods. So the method was not inherited in SubClass, so how this code is working.
Waiting for a detailed reply.
Thanks and Regards