Which two classes correctly override the getDepth method?

Given:

Which two classes correctly override the getDepth method?

Given:

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.



Leave a Reply 8

Your email address will not be published. Required fields are marked *


Tim

Tim

The answer is B E.

A: Cannot reduce the visibility of the inherited method from Deeper.

l0c

l0c

Indeed! It’s BE.

Humberto Bañuelos Flores

Humberto Bañuelos Flores

Correct answerd is B and E.

gelete

gelete

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