I would like to know the reason why this is first allowed in Java (or, in general, oops) I remember that static methods are common to the parent and child classes
public class Redefine extends Parent{ public static void test () { } } class Parent{ public static void test () { } }
Q1: Since Overriding is not supported for static methods, how can both classes contain the same methods?
Q2: If you change the method to static to throw an exception, do not compile it. why is that. Obviously this does not override, so should I be allowed to throw new exceptions correctly?
public class Redefine extends Parent{ public static void test () throws Exception{ } }
java inheritance static scjp
Sudhakar
source share