Exceptions

1

What will happen when the handler is not found for exception?

A. Calls the standard library function terminate()
B. raise an error
C. executes the remaining block
D. none of the mentioned

2

What is the output of this program?

1.
    #include 
2.
    #include 
3.
    using namespace std;
4.
    int main()
5.
    {
6.
        try {
7.
            int * array1 = new int[100000000];
8.
            int * array2 = new int[100000000];
9.
            int * array3 = new int[100000000];
10.
            int * array4 = new int[100000000];
11.
            cout << "Allocated successfully";
12.
        }
13.
        catch(bad_alloc&) {
14.
            cout << "Error allocating the 
            requested memory." << endl;
15.
        }
16.
        return 0;
17.
    }
A. Allocated successfully
B. error allocating the requested memory
C. Depends on the memory of the computer
D. none of the mentioned

3

What is the output of this program?

1.
    #include 
2.
    using namespace std;
3.
    void Funct();
4.
    int main()
5.
    {
6.
        try {
7.
            Funct();
8.
        }
9.
        catch(double) {
10.
            cerr << "caught a double type..." << endl;
11.
        }
12.
        return 0;
13.
    }
14.
    void Funct()
15.
    {
16.
        throw 3;
17.
    }
A. caught a double type
B. compile time error
C. abnormal program termination
D. none of the mentioned

4

What is the output of this program?

1.
    #include 
2.
    using namespace std;
3.
    int main()
4.
    {
5.
        char* buff;
6.
        try {
7.
            buff = new char[1024];
8.
            if (buff == 0)
9.
               throw "Memory allocation failure!";
10.
            else
11.
               cout << sizeof(buff) << "Byte
               successfully allocated!"< 
                                                    
A. 4 Bytes allocated successfully
B. 8 Bytes allocated successfully
C. Memory allocation failure
D. depends on the size of data type

5

What is the output of this program?

1.
    #include 
2.
    using namespace std;
3.
    double division(int a, int b)
4.
    {
5.
        if (b == 0) {
6.
            throw "Division by zero condition!";
7.
        }
8.
        return (a / b);
9.
    }
10.
    int main ()
11.
    {
12.
        int x = 50;
13.
        int y = 2;
14.
        double z = 0;
15.
        try {
16.
            z = division(x, y);
17.
            cout << z;
18.
        }
19.
        catch(const char *msg) {
20.
            cerr << msg;
21.
        }
22.
        return 0;
23.
    }
A. 25
B. 20
C. Division by zero condition!
D. none of the mentioned