-
What is the output of this program?
class N
{
public int K;
private int L;
}
class M extends N
{
void display()
{
super.K = super.L + 2;
System.out.println(super.K + " " + super.L);
}
}
public class inheritance_Example
{
public static void main(String args[])
{
M object = new M();
object.K=1;
object.L=2;
object.display();
}
}
-
- 3 3
- 4 4
- Compilation Error
- Runtime Error
- None of these
Correct Option: C
Class contains a private member variable L, this cannot be inherited by subclass M and does not have access to it.