class Sup{
public static String get(Integer i){
return "Sup";
}
}
class Sub extends Sup{
public static String get(Integer i) throws IOException{
return "Sub";
}
}
Above program gives compile error Exception IOException is not compatible with throws clause in Sup.get(Integer)
Both the methods are static, so it's not a case of overriding. Then why this error?
Just to make it clear that it's not a case of overriding, if I add Override annotation to subclass:
@Override
public static String get(Integer i){
return "Sub";
}
It gives compile error The method get(Integer) of type Sub must override or implement a supertype method
.
What am I missing with Exception in subclass method that is static?