Exception Handling


  1. What kind of exceptions are available in c++?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    unhandled


  1. What is meant by exception specification?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

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



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











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    A function can throw an exception of certain type only


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











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    arise an error



  1. What is the output of this program?
    #include <iostream>
    using namespace std;
    void Example() throw()
    {
    cout << "In empty()" << endl;
    }
    void WithTypeFunction() throw(int)
    {
    cout << "Will throw an int" << endl;
    throw(1);
    }
    int main()
    {
    try
    {
    Example();
    WithTypeFunction();
    }
    catch (int)
    {
    cout << "Caught an int" << endl;
    }
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

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