Home / Programming MCQs / Ruby MCQs / Question

Y

Yatendra Sir • 5.66K Points
Tutor III

Q. What will be output for the following code?

Code:
begin
         
    raise 'Exception Created!'
   
    puts 'After Exception' 
   
  rescue    
    puts 'Finally Saved!'
    
ensure
   puts 'ensure block execute'
end
(A) ensure block execute
(B) After exception! Finally Saved! ensure block execute
(C) Ecxception Created! Finally Saved! ensure block execute
(D) Finally Saved! ensure block execute
Explanation by: Yatendra Sir
The output for the following code is Option D.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.