The C++ code which causes abnormal termination or behaviour of a program should be written under _____ block.
Options
- A. catch
- B. throw
- C. try
- D. More than one of the above
- E. None of the above
Quiz Practice:
C. try
Answer: (C) try
In C++, code that may generate an exception is normally placed inside a try block.
If an exception occurs inside the try block, control can be transferred to a suitable catch block that handles the exception.
The throw statement is used to explicitly generate an exception. Therefore, the block containing code that may cause an exception is the try block.