Question
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));
}
}
What is the output of this program?
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));
}
}
Answer: Option C
Was this answer helpful ?
The code does not compile because the method calculate() in class A is final and so cannot
be overridden by method of class b.
Was this answer helpful ?
More Questions on This Topic :
Question 3.
What is Truncation is Java?
....
Submit Solution