Multiple choice

What will be the output of the program? class A { final public int GetResult(int a, int b) { return 0; } } class B extends A { public int GetResult(int a, int b) {return 1; } } public class Test { public static void main(String args[]) { B b = new B(); System.out.println("x = " + b.GetResult(0, 1));
} }

  1. x = 0

  2. x = 1

  3. Compilation fails.

  4. An exception is thrown at runtime.

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

The code doesn't compile because the method GetResult() in class A is final and so cannot be overridden.