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 Uncaught Exceptions

Posted on September 26, 2023

1. What is meant by exception specification?

A. A function is limited to throwing only a specified list of exceptions
B. A catch can catch all types of exceptions
C. A function can throw any type of exceptions
D. A try can catch all types of exceptions

View Answer

Answer: A

Explanation: 

 C++ provides a mechanism to ensure that a given function is limited to throwing only a specified list of exceptions. It is called an exception specification.

2. Identify the correct statement about throw(type).

A. A function can throw any type of exceptions
B. A function can throw an exception of certain type only
C. A function can’t throw any type of exception
D. A function can catch all types of exceptions

View Answer

Answer: B

Explanation:

 A function can throw an exception of certain type only.

3. What will happen when a programs throws any other type of exception other than specified?

A. terminate
B. arise an error
C. run
D. throw

View Answer

Answer: B

Explanation:

Because there is no way defined to catch that exception and as we know if an exception is not caught then error arises.

4. What will be the output of the following C++ code?
    #include <iostream>
    using namespace std;
    void empty() throw() 
    {
        cout << "In empty()";
    }
    void with_type() throw(int) 
    {
        cout << "Will throw an int";
        throw(1);
    }
    int main() 
    {
        try 
        {
            empty();
            with_type();
        }
        catch (int) 
        {
            cout << "Caught an int";
        }
    }

A. In empty()
B. Will throw an int
C. Caught an int
D. All of the mentioned

View Answer

Answer: D

Explanation:

 It will print all three because we are calling all functions in the main().

5. What will be the output of the following C++ code?
    #include <iostream>
    #include <exception>
    #include <typeinfo>
    using namespace std;
    class Test1
    {    
        virtual int  Funct() 
        {
        }
    };
    int main ()
    {
        try 
        {
            Test1 * var = NULL;
            typeid (*var);
        }
        catch (std::exception& typevar)
        {
            cout << "Exception: " << typevar.what() << endl;   
        }
        return 0;
    }

A. NULL
B. Exception:bad_alloc
C. Exception:std:bad_typeid
D. Exception:std:bad_type

View Answer

Answer: C

Explanation:

 As we are using a bad type on pointers, So it is arising an error.

6. What will be the output of the following C++ code?
    #include <iostream>
    #include <string>
    #include<typeinfo>
    using namespace std;
    int main( )
    {
        try
        {
            string strg1("Test");
            string strg2("ing");
            strg1.append(strg2, 4, 2);
            cout << strg1 << endl;
        }
        catch (exception &e)
        {
            cout << "Caught: " << e.what() << endl;
            cout << "Type: " << typeid(e).name() << endl;
        };
        return 0;
    }

A. out of range
B. bad type_id
C. bad allocation
D. bad type

View Answer

Answer: A

Explanation:

 As we are using out of bound value on strings, So it arising an exception.

7. What will be the output of the following C++ code?
    #include<typeinfo> 
    #include <iostream>
    using namespace std;
    class Myshape
    {
        public:
        virtual void myvirtualfunc() const {}
    };
    class mytriangle: public Myshape
    {
        public:
        virtual void myvirtualfunc() const
        {   
        };
    };
    int main()
    {
        Myshape Myshape_instance;
        Myshape &ref_Myshape = Myshape_instance;
        try 
        {
            mytriangle &ref_mytriangle = dynamic_cast(ref_Myshape);
        }
        catch (bad_cast)
        {
            cout << "Can't do the dynamic_cast lor!!!" << endl;
            cout << "Caught: bad_cast exception. Myshape is not mytriangle.\n";
        }
        return 0;
    }

A. Can’t do the dynamic_cast lor!!!
B. Caught: bad_cast exception. Myshape is not mytriangle.
C. Can’t able to create the dynamic instance for the triangle, So it is arising an exception
D. Myshape is not mytriangle

View Answer

Answer: C

Explanation:

 As we can’t able to create the dynamic instance for the triangle, So it is arising an exception.

8. What will be the output of the following C++ code?
    #include <iostream>
    using namespace std;
    int main()
    {
        char* ptr;
        unsigned long int Test = sizeof(size_t(0) / 3);
        cout << Test << endl;
        try
        {
            ptr = new char[size_t(0) / 3];
            delete[ ] ptr;
        }
        catch (bad_alloc &thebadallocation)
        {
            cout << thebadallocation.what() << endl;
        };
        return 0;
    }

A. 4
B. 2
C. bad_alloc
D. depends on compiler

View Answer

Answer: D

Explanation:

 The size of unsigned long int always depends on compiler.

9. What do you mean by “No exception specification”?

A. It throws nothing
B. It can throw anything
C. It can catch anything
D. It can try anything

View Answer

Answer: B

Explanation:

 No exception specification that it can throw anything.

10. Which operations don’t throw anything?

A. Operations which are reversible
B. Operations which are irreversible
C. Operations which are static
D. Operations which are dynamic

View Answer

Answer: B

Explanation:

 Operations which are irreversible cannot throw anything.

    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 Integer Types
  • 10+ TOP C++ MCQs on Floating Point Types
  • 10+ TOP C++ MCQs on References – 2
  • 10+ TOP C++ MCQs on Objects
  • 10+ TOP C++ MCQs on Operator Functions
  • 10+ TOP C++ MCQs on Function Call

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