Home / Programming Questions / Ruby MCQs / Page 12

Ruby MCQs with answers Page - 12

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

Yami Thakur • 9.05K Points
Tutor III

Q. Each element in an array is associated with _______.

(A) Numbers
(B) Index
(C) Integer
(D) None of the above

Y

Yami Thakur • 9.05K Points
Tutor III

Q. Array indexing in ruby starts at_________.

(A) -1
(B) 1
(C) 0
(D) Random number

Y

Yami Thakur • 9.05K Points
Tutor III

Q. In Ruby, Array index -1 represent ______.

(A) First Element
(B) Last element
(C) Middle element
(D) Reverse the array

Y

Yami Thakur • 9.05K Points
Tutor III

Q. Which of the following is correct syntax to create an array in ruby?

(A) names = Array.new
(B) names = Array.new(20)
(C) Both A and B
(D) None of the above

Y

Yami Thakur • 9.05K Points
Tutor III

Q. What will be the output of the given ruby code?

Code:
digits = Array(0...9)
puts #{digits}
(A) [0, 1, 2, 3, 4, 5, 6, 7, 8]
(B) [0, 1, 2, 3, 4, 5, 6, 7, 8]
(C) [0, 1, 2, 3, 4, 5, 6, 7, 8,9]
(D) [1, 2, 3, 4, 5, 6, 7, 8]

Y

Yami Thakur • 9.05K Points
Tutor III

Q. What will be the output of the given ruby code?

Code:
digits = Array(0..9)
num = digits.at(6)
puts #{num}
(A) 5
(B) 6
(C) 7
(D) 8

Y

Yami Thakur • 9.05K Points
Tutor III

Q. What will be the output of the given ruby code?

(A) ABC
(B) abc
(C) BCD
(D) bcd

Y

Yami Thakur • 9.05K Points
Tutor III

Q. What will be the output of the given ruby code?

Code:
a = [ a, b, c ] puts a.pack(a3a3a3)
(A) ABC
(B) abc
(C) BCD
(D) bcd

Login

Forgot username? click here

Forgot password? Click here

Don't have account? Register here.