Q:

What is the result?

0

What is the result?

class SimpleCalc
{
public int value;
public void calculate()
{
value +=7;
}
}
public class MultiCalc extends SimpleCalc
{
public void calculate()
{
value -=3;
}
public void calculate(int multiplier)
{
calculate();
super.calculate();
value *= multiplier;
}
public static void main(String args[])
{
MultiCalc calculator = new MultiCalc();
calculator.calculate(2);
System.out.println("Value is: "+ calculator.value);
}
}

  1. Value is : 8
  2. Compilation fails
  3. Value is : 12
  4. Value is : -12
  5. The code runs with no output
  6. An exception is thrown at runtime

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Correct Answer:

Value is : 8

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Core Java Multiple Choice Questions And Answers

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Which two statements are reserved words in Java? (... >>
<< What can directly access and change the value of t...