Exception Handling In Ruby - Study Mode

[#1] What is an exception in Ruby?
Correct Answer

(C) An unexpected event that disrupts the normal flow of the program

[#2] Which keyword is used to begin the exception handling block in Ruby?
Correct Answer

(D) begin

[#3] What is the purpose of the rescue keyword in Ruby?
Correct Answer

(A) To handle exceptions and execute alternative code paths

[#4] What happens if an exception is raised but not rescued in Ruby?
Correct Answer

(D) The program terminates with an error message

[#5] Which of the following is true about the ensure keyword in Ruby exception handling?
Correct Answer

(C) It is used to execute code regardless of whether an exception occurs or not