Skip to content
main-logo
  • +91 637-050-2482
  • santuitreturns@gmail.com
Menu
Menu
  • Home
  • Income Tax
    • Income From Salary
    • Profit or gain from Business/Profession.
    • Capital Gain
    • Income From Other Sources
    • 80C to 80U
    • TDS & TCS
    • ITR FORMS
  • International Taxation
    • Transfer Pricing
    • Non-Resident Taxation
    • Foreign Tax Credit (FTC)
    • Model Tax Convention
    • Base Erosion and Profit Shifting (BEPS)
  • GST
  • Accounting
  • MCQs
    • NEET
    • NEET QUIZ TEST
    • NEET PG MCQ’s
    • NEET PG QUIZ TEST
    • Civil Engineering
    • Mechanical Engineering MCQs
    • CHSL EXAM
      • Logical Reasoning
  • Others
    • Job Tips
  • CA Courses
    • CA Inter/IPCC

10+ TOP C++ MCQs on Abstract Classes – 1

Posted on September 25, 2023

1. Which class is used to design the base class?

A. abstract class
B. derived class
C. base class
D. derived & base class

View Answer

Answer: A

Explanation: 

 Abstract class is used to design base class because functions of abstract class can be overridden in derived class hence derived class from same base class can have common method with different implementation, hence forcing encapsulation.

2. Which is used to create a pure virtual function?

A. $
B. =0
C. &
D. !

View Answer

Answer: B

Explanation:

 For making a method as pure virtual function, We have to append ‘=0’ to the class or method.

3. Which is also called as abstract class?

A. virtual function
B. pure virtual function
C. derived class
D. base class

View Answer

Answer: B

Explanation:

Classes that contain at least one pure virtual function are called as abstract base classes.

4. What will be the output of the following C++ code?

    #include 
    using namespace std;
    class p 
    {
        protected:
        int width, height;
        public:
        void set_values (int a, int B.
        {
            width = a; height = b; 
        }
        virtual int area (voiD. = 0;
    };
    class r: public p
    {
        public:
        int area (voiD.
        { 
            return (width * height);
        }
    };
    class t: public p 
    {
        public:
        int area (voiD.
        {
            return (width * height / 2); 
        }
    };
    int main () 
    {
        r rect;
        t trgl;
        p * ppoly1 = ▭
        p * ppoly2 = &trgl;
        ppoly1->set_values (4, 5);
        ppoly2->set_values (4, 5);
        cout << ppoly1 -> area() ;
        cout << ppoly2 -> area();
        return 0;
    }

A. 1020
B. 20
C. 10
D. 2010

View Answer

Answer: D

Explanation:

 In this program, We are calculating the area of rectangle and triangle by using abstract class.

5. What will be the output of the following C++ code?

    #include 
    using namespace std;
    class MyInterface 
    {
        public:
        virtual void Display() = 0;
    };
    class Class1 : public MyInterface 
    {
        public:
        void Display() 
        {
            int  a = 5;
            cout << a;
        }
    };
    class Class2 : public MyInterface 
    {
        public:
        void Display()
        {
            cout <<" 5" << endl;
        }
    };
    int main()
    {
        Class1 obj1;
        obj1.Display();
        Class2 obj2;
        obj2.Display();
        return 0;
    }

A. 5
B. 10
C. 5 5
D. 15

View Answer

Answer: C

Explanation:

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

6. What will be the output of the following C++ code?

    #include 
    using namespace std;
    class sample
    {
        public:
        virtual void example() = 0; 
    };
    class Ex1:public sample
    {
        public:
        void example()
        {
            cout << "ubuntu";
        }
    };
    class Ex2:public sample
    {
        public:
        void example()
        {
            cout << " is awesome";
        }
    };
    int main()
    {
        sample* arra[2];
        Ex1 e1;
        Ex2 e2;
        arra[0]=&e1;
        arra[1]=&e2;
        arra[0]->example();
        arra[1]->example();
    }

A. ubuntu
B. is awesome
C. ubuntu is awesome
D. ubunt esome

View Answer

Answer: C

Explanation:

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

7. What will be the output of the following C++ code?

    #include 
    using namespace std;
    class Base
    {
        public:
        virtual void print() const = 0;
    };
    class DerivedOne : virtual public Base
    {
        public:
        void print() const
        {
            cout << "1";
        }
    };
    class DerivedTwo : virtual public Base
    {
        public:
        void print() const
        {
            cout << "2";
        }
    };
    class Multiple : public DerivedOne, DerivedTwo
    {
        public:
        void print() const
        {
            DerivedTwo::print();
        }
    };
    int main()
    {
        Multiple both;
        DerivedOne one;
        DerivedTwo two;
        Base *array[ 3 ];
        array[ 0 ] = &both;
        array[ 1 ] = &one;
        array[ 2 ] = &two;
        for ( int i = 0; i < 3; i++ )
        array[ i ] -> print();
        return 0;
    }

A. 121
B. 212
C. 12
D. 215

View Answer

Answer: B

Explanation:

 In this program, We are executing these based on the condition given in array. So it is printing as 212.

8. What is meant by pure virtual function?

A. Function which does not have definition of its own
B. Function which does have definition of its own
C. Function which does not have any return type
D. Function which does not have any return type & own definition

View Answer

Answer: A

Explanation:

As the name itself implies, it have to depend on other class only.

9. Pick out the correct option.

A. We cannot make an instance of an abstract base class
B. We can make an instance of an abstract base class
C. We can make an instance of an abstract super class
D. We can make an instance of an abstract derived class

View Answer

Answer: A

Explanation:

We cannot make an instance of an abstract base class.

10. Where does the abstract class is used?

A. base class only
B. derived class
C. both derived & base class
D. virtual class

View Answer

Answer: A

Explanation:

As base class only as it helps in encapsulation of similar functioning of derived classes.

    You May Also Like...

  • 10+ TOP C++ MCQs on OOPs Concept – 2
  • 10+ TOP C++ MCQs on OOPs Concept – 3
  • 10+ TOP C++ MCQs on OOPs Concept – 4
  • 10+ TOP C++ MCQs on Integer Types
  • 10+ TOP C++ MCQs on Floating Point Types
  • 10+ TOP C++ MCQs on References – 2
  • 10+ TOP C++ MCQs on References – 3
  • 10+ TOP C++ MCQs on Objects

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Quick Links

  • Home
  • About Us
  • Privacy Policy
  • Terms of Use
  • Disclaimer
  • Contact Us

Categories

  • Income Tax
  • International Taxation
  • GST
  • MCQs
  • Others
  • CA Courses

Latest Posts

  • Five changes in ITR forms of FY 2024-25 (AY 2025-26)
  • Form 10-IEA: Option to Choose Old Tax Regime
  • What is Section 54EC of the Income Tax Act?
  • What is Section 54F of the Income Tax Act?
©2025 Online Solves. All rights Reserved | Developed by AlgoPage IT Solutions Pvt. Ltd.
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept All”, you consent to the use of ALL the cookies. However, you may visit "Cookie Settings" to provide a controlled consent.
Cookie SettingsAccept All
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT