What is the output of the following application?
package mypkg; /*from ww w . j a va2 s . co m*/ class Car { protected final int process() { return 5; } } public class MyCar extends Car { public final int process() { return 3; } public static void main(String[] chips) { System.out.print(new MyCar().process()); } }
C.
The process()
method is declared final in the Car class.
The MyCar
class then attempts to override this method, resulting in a compilation error, making Option C the correct answer.