Why do we need to handle exceptions?

Ánh Dương

New member
Why do we need to handle exceptions?
A. To avoid unexpected behaviour of a program during run-time
B. To let compiler remove all exceptions by itself
C. To successfully compile the program
D. To get correct output
 
Answer: a
Explanation: We need to handle exceptions in a program to avoid any unexpected behaviour during run-time because that behaviour may affect other parts of the program. Also, an exception is detected during run-time, therefore, a program may compile successfully even with some exceptions cases in your program.
 

Tìm kiếm

Back
Top