Menu
Question Index
...

What will be the output of the following program?

final class Base {
    public void testMethod() {
        System.out.println("Final class");
    }
}
final class Inter {
    public void testMethod() {
        System.out.println("Inter Class");
    }
}
public class Sub extends Base {
    public void testMethod() {
        System.out.println("Sub class extends the Base class");
    }
    public static void main(String arg[]) {
        Sub sub = new Sub();
        Base obj = new Base();
        obj.testMethod();
        Inter inte = new Inter();
        inte.testMethod();
        sub.testMethod();
    }
}


Sub class extends the Final Base class
Inter Class
Sub class extends the Final Base class
Final class
Inter Class
Sub class extends the Final Base class
Final class
Inter Class
Final class
Some other output
Compilation Error or Runtime Error

Doubts

Problems

Topic: final Keyword In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App