Untitled Document

Subscribe here to get updates on new Videos

 

17. various possible combinations of try catch finally ?

 

 

 

previous homenext

 

Various possible combinations of try- catch- finally?

1. Whenever we are writing try block compulsory we should write catch or finally that is ‘try’ without catch or finally is invalid syntax.

2. Whenever we are writing catch block compulsory we should write try block that is catch without try is invalid.

3. Whenever we are writing finally block compulsory we should write try block. that is finally without try is invalid.

4. In try catch finally, order is important.

5. ‘try’ with multiple catch blocks Is valid but the order is important compulsory we should take from child to parent. by mistake if we are trying to take from parent to child then we will get compile time error.

6. if we are defining to catch blocks for the same exception we will get compile time error.

7. we can define try-catch-finally with in the try, with in the catch and with in finally blocks. Hence nesting of try-catch-finally is valid.

8. For try-catch-finally curly braces are mandatory.