What Will Be The Output Of The Following Java Codep Pre #68
What will be the output of the following Java code?</p> <pre><code class="language-java" line="1"> class A { final public int calculate(int a, int b) { return 1; } } class B extends A { public int calculate(int a, int b) { return 2; } } public class output { public static void main(String args[]) { B object = new B(); System.out.print("b is " + b.calculate(0, 1)); } }</code></pre>
This multiple choice question (MCQ) is related to the book/course gs gs128 Java. It can also be found in gs gs128 Java Data Types Variables Arrays - Java Type Conversions, Promotions and Castings - Quiz No.1.
What will be the output of the following Java code?
class A { final public int calculate(int a, int b) { return 1; } } class B extends A { public int calculate(int a, int b) { return 2; } } public class output { public static void main(String args[]) { B object = new B(); System.out.print("b is " + b.calculate(0, 1)); } }
b is : 2
b is : 1
Compilation Error
An exception is thrown at runtime