Home / Programming Questions / Ruby MCQs / Page 19

Ruby MCQs with answers Page - 19

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. The downcase method changes the whole string to smallcase letters.

(A) True
(B) Boolean
(C) ---
(D) ---

M

Mr. Dubey • 51.47K Points
Coach

Q. Which of the following are valid floating point literal?

(A) .5
(B) 2
(C) 0.5
(D) None of the mentioned

M

Mr. Dubey • 51.47K Points
Coach

Q. What is the role of ! at the end of the capitalize method?

(A) It is the syntax for using capitalize method
(B) It modifies the value stored in the variable
(C) It indicates the termination of string
(D) None of the mentioned

M

Mr. Dubey • 51.47K Points
Coach

Q. What will be the output of the given code?
"I'am learning Ruby Language".length.reverse.upcase

(A) 27
(B) egaugnal ybuR gninreal ma'I
(C) ERAUGNAL YBUR GNINREAL MA'I
(D) Undefined method 'reverse' for 27:Fixnum

M

Mr. Dubey • 51.47K Points
Coach

Q. What is the range of octal notation (\nnn)?

(A) 0-8
(B) 0-7
(C) 0-A
(D) None of the mentioned

M

Mr. Dubey • 51.47K Points
Coach

Q. Which of the following type of comments are valid in ruby?

(A) Single line comments
(B) Multi line comments
(C) Double line comments
(D) All of the mentioned

M

Mr. Dubey • 51.47K Points
Coach

Q. Why do we use =begin and =end?

(A) To mark the start and end of multiline comment
(B) To comment multiple lines
(C) To avoid the use of # again and again
(D) All of the mentioned

M

Mr. Dubey • 51.47K Points
Coach

Q. What is the output of the given code?
 x, y, z = 12, 36, 72
    puts "The value of x is #{ x }."
    puts "The sum of x and y is #{ x + y }."
    puts "The average was #{ (x + y + z)/3 }."

(A) 12,48,40
(B) Syntax error
(C) The value of x is 12. The sum of x and y is 48. The average was 40.
(D) None of the mentioned

Login

Forgot username? click here

Forgot password? Click here

Don't have account? Register here.