-
What is the output of this program?
class N
{
public int K;
public int L;
N()
{
K = 5;
L = 2;
}
}
class M extends N
{
int p;
M()
{
super();
}
}
public class inheritance_super_use
{
public static void main(String args[])
{
M obj = new M();
System.out.println(obj.K + " " + obj.L);
}
}
-
- 5 1
- 1 5
- 5 2
- 2 5
- None of these
Correct Option: C
Keyword super is used to call constructor of class N by constructor of class M. Constructor of a initializes K & L to 5 & 2 respectively.