What will be the result of compiling and running the following code:

public final class QTest {
    public static void main(String[] args) {
        new QTest() {
            public void show() {
    public void show() {
Compilation error will occur, because there is an attempt to instantinate an anonimous inner class, which is a subclass of final class QTest. (Classes declared with a final modifier can't have subclasses)

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Keep exploring
Java quizzes
Sign Up Now
or Subscribe for future quizzes