nerdexam
CompTIA

SY0-301 · Question #81

Which of the following pseudocodes can be used to handle program exceptions?

The correct answer is C. If program module crashes, then restart program module.. Exception handling is the process of detecting a runtime error or unexpected condition and responding to it gracefully to keep the program functional. Option C - 'If program module crashes, then restart program module' - is a textbook example: it detects a failure event (module c

Threats, vulnerabilities, and mitigations

Question

Which of the following pseudocodes can be used to handle program exceptions?

Options

  • AIf program detects another instance of itself, then kill program instance.
  • BIf user enters invalid input, then restart program.
  • CIf program module crashes, then restart program module.
  • DIf user's input exceeds buffer length, then truncate the input.

How the community answered

(30 responses)
  • A
    7% (2)
  • B
    3% (1)
  • C
    90% (27)

Explanation

Exception handling is the process of detecting a runtime error or unexpected condition and responding to it gracefully to keep the program functional. Option C - 'If program module crashes, then restart program module' - is a textbook example: it detects a failure event (module crash) and takes a corrective action (restart the module) to recover. Option A describes process management (killing a duplicate instance). Option B describes input validation with a restart response, not true exception handling. Option D describes input sanitization to prevent buffer overflows - also input validation, not exception handling.

Topics

#exception handling#secure coding#error handling#input validation

Community Discussion

No community discussion yet for this question.

Full SY0-301 Practice