answersLogoWhite

0


Best Answer

Yes, a try-catch block can be nested. It is placed around the code that might generate an exception.

User Avatar

Wiki User

9y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Can a try block have nested try blocks?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is meant by the phrase one block of code can be nested in another?

It simply means one code block contains another code block. How you achieve this depends on the language, but in many languages we use opening and closing braces to define a code block. function foo () { // start of function block { // start of nested block // ... } // end of nested block } // end of function block Nested code blocks are typically used to define a new scope within an existing scope. Any variables declared within the nested block are local to the scope of that block and will fall from scope when we exit the nested block. This can be useful when we want to instantiate new variables within a larger scope but want to localise them to the code block that actually uses them. In some languages (such as C++) this also allows us to redefine names that were initially defined by the enclosing scope, temporarily hiding the original names from within the nested scope (only the local names are visible). When we exit the nested block, the original names become visible again. However, referring to two separate variables by the same name within two scopes of the same function can make code difficult to read, so this is best avoided.


How many catch blocks can you use with one try block with example?

A try block can have multiple catch blocks, each handling a different type of exception. Be careful about the order of laying the exceptions. Using Exception at the top will catch everything that is derived from it, thereby missing the other specfic exception catches. And there can also be only one finally block.


Why use catch keyword in java?

no, because catch is used to handle exceptions which are generated from try block


Can css comments be nested?

No, the CSS specifications explicitly state that CSS comments cannot be nested. If you try to do this, then your nested comments closing delimiter */ will close out the larger comment and anything after it will be rendered by the web browser. When comments are nested, the nested comment's beginning delimiter /* is ignored yet the closing */ is not.


How do you use try block in cpp?

A try statement is used in conjunction with one or more catch blocks to provide exception handling. If an exception is thrown by a try block, the corresponding catch block will handle the exception. If no catch block is provided for a particular exception, then a runtime error occurs instead. Try-catch statements are used to provide graceful resolutions to potential runtime errors.

Related questions

What is meant by the phrase one block of code can be nested in another?

It simply means one code block contains another code block. How you achieve this depends on the language, but in many languages we use opening and closing braces to define a code block. function foo () { // start of function block { // start of nested block // ... } // end of nested block } // end of function block Nested code blocks are typically used to define a new scope within an existing scope. Any variables declared within the nested block are local to the scope of that block and will fall from scope when we exit the nested block. This can be useful when we want to instantiate new variables within a larger scope but want to localise them to the code block that actually uses them. In some languages (such as C++) this also allows us to redefine names that were initially defined by the enclosing scope, temporarily hiding the original names from within the nested scope (only the local names are visible). When we exit the nested block, the original names become visible again. However, referring to two separate variables by the same name within two scopes of the same function can make code difficult to read, so this is best avoided.


How come a person can block me from thir Facebook and when i try to block them it says no results?

If someone blocks or unfriends it works both ways. If someone blocks you they should no longer appear on your fb 'home'


The average on every block in Detroit?

Give us the names of all the blocks and we'll try and answer it.


How many catch blocks can you use with one try block with example?

A try block can have multiple catch blocks, each handling a different type of exception. Be careful about the order of laying the exceptions. Using Exception at the top will catch everything that is derived from it, thereby missing the other specfic exception catches. And there can also be only one finally block.


Why use catch keyword in java?

no, because catch is used to handle exceptions which are generated from try block


Can css comments be nested?

No, the CSS specifications explicitly state that CSS comments cannot be nested. If you try to do this, then your nested comments closing delimiter */ will close out the larger comment and anything after it will be rendered by the web browser. When comments are nested, the nested comment's beginning delimiter /* is ignored yet the closing */ is not.


Is there a minecraft mod which allows you to be 1 block tall for 1.2.5?

Yes, try searching Minecraft Little blocks Mod


How do you use try block in cpp?

A try statement is used in conjunction with one or more catch blocks to provide exception handling. If an exception is thrown by a try block, the corresponding catch block will handle the exception. If no catch block is provided for a particular exception, then a runtime error occurs instead. Try-catch statements are used to provide graceful resolutions to potential runtime errors.


What is the plural for block?

The plural form for the noun block is blocks.


Elements can be categorized into how many blocks based on their number of electron orbitals?

Elements can be categorized into 4 differents blocks, s block, d block, p block and f block.


How tall is 20 block?

It depends on what type of blocks, and the sizes of the blocks.


How many Chevy small blocks are there?

350 and under are small blocks. There is also a 400 small block but there is a 400 large block. 396 and up are big blocks.