Vidyalelo
Java Programming · Q35

Overriding and Overloading

Programming · Java Programming · question 35

Q35

What will be printed after executing following program code? class Base int value = 0; Base() addValue(); void addValue() value += 10; int getValue() return value; class Derived extends Base Derived() addValue(); void addValue() value += 20; public class Test public static void main(String[] args) Base b = new Derived(); System.out.println(b.getValue());

A.
10
B.
20
C.
30
D.
40
Answer
E.
None of these

Answer: Option D

Solution

Answer: Option D
No explanation is given for this question Let's Discuss on Board