Method Overloading And Overriding
6.What happens if we override a method and change its return type in Java?
-
A. The return type can be changed freely
-
B. A compilation error occurs unless it's a covariant return type
-
C. The superclass method is ignored
-
D. Both methods execute at runtime
A compilation error occurs unless it's a covariant return type
A compilation error occurs unless it's a covariant return type
7.What is the role of the super keyword in method overriding?
-
A. It is mandatory to use when overriding a method
-
B. It allows calling the superclass version of an overridden method
-
C. It prevents method overriding
-
D. It is used to define a new method instead of overriding
It allows calling the superclass version of an overridden method
It allows calling the superclass version of an overridden method