Home / Programming Questions / Ruby MCQs / Page 15

Ruby MCQs with answers Page - 15

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

M

Mr. Dubey • 51.47K Points
Coach

Q. Which method is used to write content in the file ?

(A) systemwrite
(B) sysputs
(C) syswrite
(D) systemputs

M

Mr. Dubey • 51.47K Points
Coach

Q. Which of the following is correct difference between foreach and readlines?

(A) The method readline does not return an array.
(B) The method foreach does not return an array.
(C) readline is associated with a block
(D) Both A and C

M

Mr. Dubey • 51.47K Points
Coach

Q. Which of the method is used to returns the contents of the file line by line?

(A) IO.read
(B) IO.foreach
(C) IO.syswrite
(D) IO.readlines

M

Mr. Dubey • 51.47K Points
Coach

Q. Which method is used to change the mode or permissions/access list of a file?

(A) mode
(B) chmod
(C) access
(D) permissions

Y

Yatendra Sir • 5.66K Points
Tutor III

Q. In ruby, Exception handling is a process which describes a way to handle the __________.

(A) unwanted Event
(B) unexpected event
(C) Both A and B
(D) None of the above

Y

Yatendra Sir • 5.66K Points
Tutor III

Q. Which statement is used to execute the rescue block again from the beginning after capturing the exception?

(A) retry
(B) raise
(C) ensure
(D) else

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!'
    
retry
end
(A) Finally Saved!
(B) After Exception
(C) Exception Created!
(D) Infinite Loop

Y

Yatendra Sir • 5.66K Points
Tutor III

Q. Raise Statement is used for?

(A) statement is used to raise an exception
(B) statement is used to solve an exception
(C) statement is used to raise and solve an exception
(D) None of the above

Login

Forgot username? click here

Forgot password? Click here

Don't have account? Register here.