Sail E0 Webinar
Question


What is the output of this program?


class A {
public int i;
public int j;
A() {
i = 1;
j = 2;
}
}
class B extends A {
int a;
B() {
super();
}
}
class super_use {
public static void main(String args[])
{
B obj = new B();
System.out.println(obj.i + " " + obj.j)
}
}
Options:
A .  1 2
B .  2 1
C .  Runtime Error
D .  Compilation Error
Answer: Option A

Keyword super is used to call constructor of class A by constructor of class B. Constructor of 


Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers