Home » C++ Programming » Exception Handling » Question
  1. What is the output of this program?
    #include <iostream>
    #include <exception>
    using namespace std;
    struct NewException : public exception
    {
    const char * what () const throw ()
    {
    return "Interview Mania";
    }
    };
    int main()
    {
    try
    {
    throw NewException();
    }
    catch(NewException& e)
    {
    cout << "Exception Caught..." << std::endl;
    cout << e.what() << std::endl;
    }
    catch(std::exception& e)
    {
    }
    }
    1. Compilation Error
    2. Exception Caught...
    3. Interview Mania
    4. Runtime Error
    5. Exception Caught...
      Interview Mania
Correct Option: E

We are defining the user-defined exception in this program.



Your comments will be displayed only after manual approval.