Home / Programming MCQs / Ruby MCQs / Question

Y

Yatendra Sir • 5.60K 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:

The output for the following code is Option D.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.