Which statement is used to explicitly generate an exception in C++?
Options
- A. try
- B. catch
- C. throw
- D. More than one of the above
- E. None of the above
Quiz Practice:
C. throw
Answer: (C) throw
The throw statement is used to explicitly generate or raise an exception in C++.
For example, throw 10; can be used to throw an integer exception.
The try block contains code where an exception may occur, while the catch block is used to handle an exception.
Therefore, throw is the correct answer.