Skip to content
Related Articles

Related Articles

Java | Inheritance | Question 2
  • Difficulty Level : Easy
  • Last Updated : 24 Nov, 2013




class Base {
    final public void show() {
       System.out.println("Base::show() called");
    }
}
   
class Derived extends Base {
    public void show() {
       System.out.println("Derived::show() called");
    }
}
   
class Main {
    public static void main(String[] args) {
        Base b = new Derived();;
        b.show();
    }
}

(A) Base::show() called
(B) Derived::show() called
(C) Compiler Error
(D) Runtime Error


Answer: (C)

Explanation: Final methods cannot be overridden. See the compiler error here.

Quiz of this Question

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up
Recommended Articles
Page :