Multiple choice

What will be the output of the following program code? publicclassSuperdenmo { publicstaticvoid main(String[] args) { B b=new B(); b.add(); b.display(); } } class A { intx,y; A() { x=10; y=20; } } class B extends A { intx,y,a,b; B() { x=100; y=200; } void add() { a=x+super.x;
b=y+super.y; } void display() { System.out.print(“value of a=”+a+nvalue of b=+b); } }

  1. value of a=110value of b=220

  2. value of a=10value of b=20

  3. value of a=100value of b=200

  4. value of a=100value of b=220

  5. none of the above

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

As super keyword is used to call constructor of parent class, the output of above program will bea=x+super.xb=y+super.ya=100+10=110b=200+20=220.