Home / Programming Questions / Ruby MCQs / Page 16
Dear candidates you will find MCQ questions of Ruby here. Learn these questions and prepare yourself for coming examinations and interviews. You can check the right answer of any question by clicking on any option or by clicking view answer button.
Share your questions by clicking Add Question
Y
Q. What will be output for the following code?
begin puts 'This is Before Exception Arise!' raise 'Exception Created!' puts 'After Exception' end
Y
Q. Which statement will execute at the end of the code, whether the exception raise or not?
Y
Q. What will be output for the following code?
begin raise 'Exception Created!' puts 'After Exception' rescue puts 'Finally Saved!' ensure puts 'ensure block execute' end
Y
Q. Which block only executes when no exception is raised?
Y
Q. What will be output for the following code?
begin puts 'no Exception raise' rescue puts 'Finally Saved!' else puts 'Else block execute because of no exception raise' ensure puts 'ensure block execute' end
Y
Q. What will be output for the following code When input number is ""!""?
def catch_and_throw(value) puts value a = readline.chomp throw :value_e if a == ""!"" return a end catch :value_e do number = catch_and_throw(""Enter Number: "") end
M
Q. Why is gets not preferred instead of gets.chomp?
M
Q. Why can not we use quotation marks (' or ") with boolean?
Don't have account? Register here.