Which is the first line to fail to compile?
class Shape { void use() { } // r1 } ? class Rectangle extends Shape { private void use(String s) { } // r2 public void bang() { } // r3 }
D.
The Rectangle class is a subclass of the Shape class.
The use()
method has a different signature so it is not an override.
It is fine that the access modifier is stricter, and Option D is correct.
Line r3 is a valid method unrelated to the superclass.