engineering computer science MCQ #1241

What is the purpose of a try-catch block?

engineering computer science MCQ #1241

  1. Question 1

    Q1. What is the purpose of a try-catch block?

    • A) To handle runtime errors
    • B) To optimize code performance
    • C) To improve code readability
    • D) To reduce code complexity

    Answer: To handle runtime errors

    Explanation: A try-catch block is used to handle runtime errors by catching exceptions and executing alternative code, preventing program crashes and improving robustness.