Nested try blocks both inner & outer catch handlers are not able to handle the exception

Q.  In nested try blocks, if both inner and outer catch handlers are not able to handle the exception, then ______________ .

- Published on 17 Jul 15

a. Compiler executes only executable statements of main().
b. Compiler issues compile time errors about it.
c. Program will be executed without any interrupt.
d. Program will be terminated abnormally.

ANSWER: Program will be terminated abnormally.
 

    Discussion

  • Raj   -Posted on 24 Oct 15
    In nested try blocks, if both inner and outer catch handlers are not able to handle the exception, then Program will be terminated abnormally.
    Example:
    class MyClass
    {
    public:
    void show()
    {
    try
    {
    char x= 'c';
    try
    {
    throw 'x';
    }
    catch(float f)
    {
    cout << ”float type catch block”;

    }
    }
    catch(int x)
    {
    cout << ”Integer type catch block”;
    }
    }
    };
    void main()
    {
    MyClass obj;
    obj.show();
    }
    The above program will be terminated abnormally because there is not any catch block related to char.

Post your comment / Share knowledge


Enter the code shown above:
 
(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)