Menu
Question Index
...

What will be the output of the following program?

class Result
{
    public static void main(String args[])
    {
        A b = new B();
        System.out.println("x = " + b.getResult(0, 1));  
    }
}

class B extends A
{
    final public int getResult(int a, int b) { return a + b; }
}

class A extends Result
{
    public int getResult(int a, int b) { return a * b; }
}


x = 0
x = 1
Compilation Error
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