Which statement(s) are correct about the following code? (Choose all that apply)
public class Shape { protected static Integer print() throws Exception { System.out.println("Shape is printing"); return 1; } } public class Rectangle extends Shape { public Number print() throws RuntimeException { System.out.println("Rectangle is printing"); return 2; } }
C, E.
The code doesn't compile, so A is incorrect.
B is not correct since overriding a method allows a subclass to define a method with an exception that is a subclass of the exception in the parent method.
C is correct because the return types are not covariant; Number is not a subclass of Integer.
D is incorrect because the subclass defines a method that is more accessible than the method in the parent class, which is allowed.
E is correct because the method is declared as static in the parent class and not so in the child class.