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

    abstract class n
    {
    int K;
    abstract void display();
    }
    class m extends n
    {
    int L;
    void display()
    {
    System.out.println(L);
    }
    }
    public class Abstract_class_Example
    {
    public static void main(String args[])
    {
    m obj = new m();
    obj.L=5;
    obj.display();
    }
    }
    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
Correct Option: E

class n is an abstract class, it contains a abstract function display(), the full implementation of display() method is given in its subclass m, Both the display functions are the same. Prototype of display() is defined in class n and its implementation is given in class m.
output: 5



Your comments will be displayed only after manual approval.