Home » C++ Programming » Classes & Objects » Question
  1. What is the output of this program?
    #include <iostream>
    using namespace std;
    class InterfaceClass
    {
    public:
    virtual void Display() = 0;
    };
    class ClassA : public InterfaceClass
    {
    public:
    void Display()
    {
    int num = 10;
    cout << num;
    }
    };
    class ClassB : public InterfaceClass
    {
    public:
    void Display()
    {
    cout <<" 14" << endl;
    }
    };
    int main()
    {
    ClassA object1;
    object1.Display();
    ClassB object2;
    object2.Display();
    return 0;
    }
    1. 10
    2. 14
    3. 14 10
    4. 10 14
    5. None of these
Correct Option: D

In this program, We are displaying the data from the two classes
by using abstract class.



Your comments will be displayed only after manual approval.