Home » C++ Programming » Exception Handling » Question
  1. What is the output of this program?
    #include <iostream>
    #include <exception>
    using namespace std;
    int main ()
    {
    try
    {
    int* myarray = new int[150];
    cout << "Memory Allocated...";
    }
    catch (exception& e)
    {
    cout << "Standard Exception occurred..." << e.what() << endl;
    }
    return 0;
    }
    1. Memory Allocated...
    2. Compilation Error
    3. Runtime Error
    4. Garbage Value
    5. None of these
Correct Option: A

In this program, We are allocating the memory for array. If it is allocated means, no exception will arise and if there is no size in memory means, Exception will arise.



Your comments will be displayed only after manual approval.