Which statement, when inserted at (1), will call the print()
method in the Shape class.
class Shape { public void print() { System.out.println("base"); }/* w w w . j av a 2 s . c o m*/ } class Rectangle extends Shape { public void print() { System.out.println("extension"); // (1) INSERT CODE HERE. } } public class Main { public static void main(String[] args) { Rectangle ext = new Rectangle(); ext.print(); } }
Select the one correct answer.
print()
;print()
;print()
;print()
;print()
;(d)
Overridden method implementations are accessed using the super keyword.
Statements like print()
, Shape.print()
, and Shape.this.print()
will not work.