What is the output of the following Java program no. 12?

  1. class Base
  2. {
  3.     protected final void getInfo()
  4.     {
  5.         System.out.println(“method of Base class”);
  6.     }
  7. }
  8. public class Derived extends Base
  9. {
  10.     protected final void getInfo()
  11.     {
  12.         System.out.println(“method of Derived class”);
  13.     }
  14.     public static void main(String[] args)
  15.     {
  16.         Base obj = new Base();
  17.         obj.getInfo();
  18.     }
  19. }

Output

	Derived.java:11: error: getInfo() in Derived cannot override getInfo() in Base
    protected final void getInfo()
                         ^
  overridden method is final
1 error

Explanation

The getDetails() method is final; therefore it can not be overridden in the subclass.