1. What is an exception in Ruby? 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 Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option C No explanation is given for this question Let's Discuss on Board
2. Which keyword is used to begin the exception handling block in Ruby? A. rescue B. try C. catch D. begin Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option D No explanation is given for this question Let's Discuss on Board
3. 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 & Solution Discuss in Board Save for Later Answer & Solution Answer: Option A No explanation is given for this question Let's Discuss on Board
4. 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 Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option D No explanation is given for this question Let's Discuss on Board
5. Which of the following is true about the ensure keyword in Ruby exception handling? A. It is used to define a new module B. It is used to create a new instance of a class C. It is used to execute code regardless of whether an exception occurs or not D. It is used to add module methods to a single object Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option C No explanation is given for this question Let's Discuss on Board
6. What is the purpose of the raise keyword in Ruby? A. To begin an exception handling block B. To manually raise an exception C. To ensure code execution regardless of exceptions D. To begin an exception handling block Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option B No explanation is given for this question Let's Discuss on Board
7. What is the purpose of the ensure keyword in Ruby? A. To create a new instance of a class B. To define a new module C. To execute code regardless of whether an exception occurs or not D. To handle exceptions and execute alternative code paths Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option C No explanation is given for this question Let's Discuss on Board
8. What is the purpose of using exception handling in Ruby? A. To define instance methods in a class B. To create a new instance of a class C. To add module methods to a single object D. To gracefully handle errors and prevent program crashes Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option D No explanation is given for this question Let's Discuss on Board
9. What is the main advantage of using exception handling in Ruby? A. It allows for graceful recovery from errors B. It prevents errors from occurring C. It simplifies the syntax of Ruby code D. It improves the performance of Ruby programs Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option A No explanation is given for this question Let's Discuss on Board
10. What happens if an exception is raised within a rescue block in Ruby? A. The program enters a loop to retry the operation B. The program continues execution as normal C. The program terminates with an error message D. The exception is handled by an outer rescue block, if present Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option D No explanation is given for this question Let's Discuss on Board