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

TOP 10 C++ MCQs on Class Hierarchies Introduction

Posted on September 27, 2023

1. What will happen when introduce the interface of classes in a run-time polymorphic hierarchy?

A. Separation of interface from implementation
B. Merging of interface from implementation
C. Separation of interface from debugging
D. Merging of interface from debugging

View Answer

Answer: A

Explanation: 

: Separation of interface from implementation introduce the interface of classes in a run-time polymorphic hierarchy.

2. Which classes are called as mixin?

A. Represent a secondary design
B. Classes express functionality which represents responsibilities
C. Standard logging stream
D. Represent a priary design

View Answer

Answer: B

Explanation:

: A class that expresses functionality rather than its primary design role is called a mixin.

3. What is the use of clog?

A. Standard logging stream
B. Error stream
C. Input stream
D. output stream

View Answer

Answer: A

Explanation:

: clog is an object of class ostream that represents the standard logging stream. It is associated with the cstdio stream stderr, like cerr.

4. What will be the output of the following C++ code?
    #include <iostream>
    #include <sstream>
    using namespace std;
    int main()
    {
        stringstream mys(ios :: in | ios :: out);
        std :: string dat("The double value is : 74.79 .");
        mys.str(dat);
        mys.seekg(-7, ios :: enD.;
        double val;
        mys >> val;
        val = val*val;
        mys.seekp(-7,ios::enD.;
        mys << val;
        std :: string new_val = mys.str();
        cout << new_val;
        return 0;
    }

A. 5593.54
B. Error
C. Runtime error
D. 5463.54

View Answer

Answer: A

Explanation:

: In this program, We have used the string hierarchy to compute the square of the number.

5. What will be the output of the following C++ code?
    #include <iostream>
    using namespace std;
    class Base
    {
        public:
            Base(){}
            ~Base(){}
            protected:
            private: 
    };
    class Derived:public Base
    {
        public:
            Derived(){}
            Derived(){}
            private:
            protected:
    };
    int main()
    {
        cout << "The program exceuted" << endl;
    }

A. The program executed
B. Error
C. Runtime error
D. program exceuted

View Answer

Answer: B

Explanation:

: We are allowed to overload constructor but in this case as both the constructor have no parameters which implies that both the constructor have same signature which is not allowed i.e. constructors can be overloaded but two overloaded constructors can not have same function signature.

6. What will be the output of the following C++ code?
    #include <iostream>
    using namespace std;
    class MyException
    {
        public:
        MyException(int value) : mValue(value)
        {
        }
        int mValue;
    };
    class MyDerivedException : public MyException
    {
        public:
            MyDerivedException(int value, int anotherValue) : MyException(value),    mAnotherValue(anotherValue)
            {
            }
            int mValue;
            int mAnotherValue;
    };
    void doSomething()
    {
        throw MyDerivedException(10,20);
    }
    int main()
    {
        try
        {
            doSomething();
        }
        catch (MyDerivedException &exception)
        {
            cout << "\nCaught Derived Class Exception\n";
        }
        catch (MyException &exception)
        {
            cout << "\nCaught Base Class Exception\n";
        }
        return 0;
    }

A. Caught Base Class Exception
B. Caught Derived Class Exception
C. Caught Base & Derived Class Exception
D. Caught Base Class

View Answer

Answer: B

Explanation:

: As we are throwing the value from the derived class, it is arising an exception in derived class

7. What will be the output of the following C++ code?
    #include <iostream>
    #include <string>
    using namespace std;
    int main() 
    {
        string s = "a long string";
        s.insert(s.size() / 2, " * ");
        cout << s << endl;
        return 0;
    }

A. a long* string
B. a long st*ring
C. Depends on compiler
D. a long string

View Answer

Answer: C

Explanation:

: In this program, We are placing the string based on the size of the string and it is a string hierarchy.

8. How many types of guarantees are there in exception class can have?

A. 1
B. 2
C. 3
D. 4

View Answer

Answer: C

Explanation:

: There are three types of guarantees in c++. They are weak, strong and no-throw.

10. What does the cerr represent?

A. Standard error stream
B. Standard logging stream
C. Input stream
D. Output stream

View Answer

Answer: D

Explanation:

: cerr is an object of class ostream that represents the standard error stream. It is associated with the cstdio stream stderr.

    You May Also Like...

  • 10+ TOP MCQs on C++ vs C
  • 10+ TOP MCQs on C++ Concepts
  • 10+ TOP C++ MCQs on Void
  • 10+ TOP C++ MCQs on Pointer to Void
  • 10+ TOP C++ MCQs on Pointer to Structures
  • 10+ TOP C++ MCQs on Operator Overloading – 2
  • 10+ TOP C++ MCQs on Complex Number Type
  • 10+ TOP C++ MCQs on String Class

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