Choose the correct statement about the following code:
1: interface Shape { 2: abstract int getBorders(); 3: } 4: abstract class Square implements Shape { 5: abstract int getArea(); 6: } 7: public class Rectangle extends Square { 8: int getArea() { return 6; } 9: }
D.
The code fails to compile because Rectangle, the first concrete subclass, doesn't implement getBorders()
, which is inherited as an abstract method.
Option D is correct.
Option B is incorrect because there is nothing wrong with this interface method definition.
Option C is incorrect because an abstract class is not required to implement any abstract methods, including those inherited from an interface.
Option E is incorrect because the code fails at compilation-time.