What is the purpose of the rescue keyword in Ruby?
A. To handle exceptions and execute alternative code paths
B. To define a new module
C. To create a new instance of a class
D. To add module methods to a single object
Answer: Option A
A. A way to group related methods and constants
B. A method for defining variables
C. An unexpected event that disrupts the normal flow of the program
D. A predefined object in Ruby
Which keyword is used to begin the exception handling block in Ruby?
A. rescue
B. try
C. catch
D. begin
What is the purpose of the rescue keyword in Ruby?
A. To handle exceptions and execute alternative code paths
B. To define a new module
C. To create a new instance of a class
D. To add module methods to a single object
What happens if an exception is raised but not rescued in Ruby?
A. The program prompts the user to fix the error
B. The program enters a loop to retry the operation
C. The program continues execution as normal
D. The program terminates with an error message
Join The Discussion