Home / MCQ Bank / Computer
Computer Overriding And Overloading Difficulty: Medium

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()); } }

Select the correct option to test your answer:

More Computer Questions

What is the purpose of the MapReduce "Partitioner"? In desktop which browser does not support WebSocket? Which of the following are themselves a collection of different data types? Which of the following is true about the base plotting system? What will be the output of the following C code? #include <stdio.h> int main() { int y = 2; int z = y +(y = 10); printf("%d\n", z); }