JAVA If class Triangle implements the Geometry interface and

JAVA: If class Triangle implements the Geometry interface, and class RightTriangle extends Triangle, which of the following would not compile?

(a) Geometry g = new Geometry()

(b) Geometry g = new Triangle();

(c) Geometry g = new RightTriangle();

(d) Triangle t = new RightTriangle();

Solution

Answer : (a) Geometry g = new Geometry()

You can\'t instantiate an interface directly, but you can instantiate a class that implements that interface

JAVA: If class Triangle implements the Geometry interface, and class RightTriangle extends Triangle, which of the following would not compile? (a) Geometry g =

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site