Which of the following is the most preferred way of throwing and handling exceptions
Answers
Answered by
2
Answer:
Throw by reference and catch by reference.
Answered by
0
The most preferred way of throwing and handling exceptions is to throw by reference and catch by reference.
- Throwing and handling exceptions by reference is better than by value as it is much more optimal and efficient.
- If we want to change the value of the variable later then this will cause problems if we throw and handle exceptions by value instead of reference.
- Another problem that arises is object slicing.
- Thus, throw by reference and catch by reference improves performance and the preferred way of throwing and handling exceptions
Similar questions