Home » JAVA Programming » Abstraction » Question
  1. What is the output of this program?

    class N
    {
    public int K;
    public int L;
    N()
    {
    K = 5;
    L = 6;
    }
    }
    class M extends N
    {
    int p;
    M()
    {
    super();
    }
    }
    public class super_Example
    {
    public static void main(String args[])
    {
    M object = new M();
    System.out.println(object.K + " " + object.L);
    }
    }
    1. 5 6
    2. 6 5
    3. Compilation Error
    4. Runtime Error
    5. None of these
Correct Option: A

Keyword super is used to call constructor of class N by constructor of class M. Constructor of a initializes K & L to 5 & 6 respectively.



Your comments will be displayed only after manual approval.