Skip to content
Related Articles

Related Articles

Java | final keyword | Question 4
  • Last Updated : 09 Jan, 2014
GeeksforGeeks - Summer Carnival Banner

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

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

Answer: (C)

Explanation: compiler error: show() in Derived cannot override show() in Base

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 :