Home » JAVA Programming » Abstraction » Question
  1. 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();
    }
    }
    1. 3 3
    2. 4 4
    3. Compilation Error
    4. Runtime Error
    5. 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.



Your comments will be displayed only after manual approval.