What is the output of the following code?
1: abstract class Shape { 2: public final void print() { System.out.println("Shape prints"); } 3: public static void main(String[] args) { 4: Shape shape = new Rectangle(); 5: shape.print(); 6: } 7: } 8: public class Rectangle extends Shape { 9: public void print() { System.out.println("Rectangle prints"); } 10: }
E.
The code doesn't compile, so A and B are incorrect.
line 9 print() is marked as final in the superclass Shape, which means it cannot be overridden.