Home » C++ Programming » Classes & Objects » Question
  1. What is the output of this program?
    #include <iostream>
    using namespace std;
    class ClassA
    {
    public:
    virtual void example() = 0;
    };
    class ClassB:public ClassA
    {
    public:
    void example()
    {
    cout << "Interview Mania";
    }
    };
    class ClassC:public ClassA
    {
    public:
    void example()
    {
    cout << " is awesome.";
    }
    };
    int main()
    {
    ClassA* array[2];
    ClassB B;
    ClassC C;
    array[0]=&B;
    array[1]=&C;
    array[0]->example();
    array[1]->example();
    }
    1. Interview Mania
    2. Interview Mania is awesome.
    3. is awesome.
    4. Compilation Error
    5. None of these
Correct Option: B

In this program, We are combining the two statements from two classes and printing it by using abstract class.



Your comments will be displayed only after manual approval.