Home » C++ Programming » Exception Handling » Question
  1. What is the output of this program?
    #include <iostream>
    #include <string>
    #include <typeinfo>
    using namespace std;
    int main( )
    {
    try
    {
    string str1("Interview");
    string str2("Mania");
    str1.append(str2, 6, 3);
    cout << str1 << " " << endl;
    }
    catch (exception &e)
    {
    cout << "Caught: " << e.what() << endl;
    cout << "Type: " << typeid(e).name() << endl;
    };
    return 0;
    }
    1. Compilation Error
    2. Runtime Error
    3. out_of_range
    4. Garbage value
    5. None of these
Correct Option: C

out_of_range



Your comments will be displayed only after manual approval.