Which two classes correctly override the getDepth method?
A.
public class deep extends Deeper {
protected Integer getDepth(){
return 5;
}}
B.
public class deep extends Deeper {
public Double getDepth() {
return 5d;
}}
C.
public class deep extends Deeper {
public String getDepth () {
}}
D.
public class deep extends Deeper {
public Long getDepth (int d) {
return 5L;
}}
E.
public class deep extends Deeper {
public Short getDepth () {
return 5;
}}
Explanation:
Note: The abstract class Number is the superclass of classes Byte, Double, Float, Integer, Long,
and Short.
Subclasses of Number must provide methods to convert the represented numeric value to byte,
double, float, int, long, and short.
When class C extends B, we say that C is a “subclass” of B, and B is the “superclass” of C. This is
called inheritence, because C inherited from B.
The answer is B E.
A: Cannot reduce the visibility of the inherited method from Deeper.
+1
+1
+1
Indeed! It’s BE.
Correct answerd is B and E.
B,E
A. False: protected: Cannot reduce the visibility of the inherited method from Deeper
B. True : Double
C. False: String: The return type is incompatible with Deeper.getDepth()
D. False: (int d): It’s not the override, but overload.
E. True : Short
be