From which problems is it possible for a program to recover?

  1. Errors

  2. Exceptions

  3. Both errors and exceptions

  4. Neither.


Correct Option: B
Explanation:

To answer this question, the user needs to know the difference between errors and exceptions in programming.

Errors are problems that prevent the program from running entirely. They can occur due to syntax errors, logical errors, or runtime errors. When an error occurs, the program usually stops executing, and the user must fix the error before running the program again.

Exceptions, on the other hand, are problems that occur during the execution of a program. They are caused by unexpected situations or events that the program may not have been designed to handle. When an exception occurs, the program can often recover from the problem and continue executing, or it may terminate.

Now, let's examine each option:

A. Errors: Programs cannot recover from errors. Errors are fatal problems that prevent the program from running, so there is no opportunity for recovery.

B. Exceptions: Programs can recover from exceptions. Exceptions are unexpected problems that can be caught and handled by the program, allowing it to continue executing.

C. Both errors and exceptions: This option is incorrect. Programs cannot recover from errors, but they can recover from exceptions.

D. Neither: This option is incorrect. Programs can recover from exceptions, even if they cannot recover from errors.

Therefore, the answer is: B. Exceptions

Find more quizzes: