A

Admin • 802.91K Points
Coach

Q. 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));
}
}

  • (A) b is : 2
  • (B) b is : 1
  • (C) Compilation Error
  • (D) An exception is thrown at runtime
  • Correct Answer - Option(C)
  • Views: 3
  • Filed under category Java
  • Hashtags:

No solution found for this question.
Add Solution and get +2 points.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.