Home / Programming Questions / Ruby MCQs / Page 13

Ruby MCQs with answers Page - 13

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. What will be the output of the given ruby code?

Code:
arr = [1, 2, 3, 4]
print arr
(A) [1, 2, 3, 4]
(B) 1234
(C) error
(D) Infinite Loop

Y

Yami Thakur • 9.05K Points
Tutor III

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

Code:
array = [100, 200, 300, 400, 500]
print array[4]
(A) [100, 200, 300, 400, 500]
(B) 300
(C) 400
(D) 500

Y

Yami Thakur • 9.05K Points
Tutor III

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

Code:
string_array = [a,e,i,o,u]
print string_array
(A) Error
(B) ["a","e","i","o","u"]
(C) aeiou
(D) Infinite Loop

Y

Yami Thakur • 9.05K Points
Tutor III

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

Code:
string_array = [a,e,i,o,u]
print string_array[3]
(A) ["a","e","i","o","u"]
(B) e
(C) i
(D) o

Y

Yami Thakur • 9.05K Points
Tutor III

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

Code:
arr = [[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]]
print arr
(A) [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]].
(B) [0, 0, 0, 0][0, 0, 0, 0]
(C) [0, 0, 0, 0]
(D) error

Y

Yami Thakur • 9.05K Points
Tutor III

Q. What is the output of the given ruby code?

Code:
a=[[a,b]]
b=[[e,a]]
print a + b
(A) [["a", "b"], ["e", "a"]].
(B) [["2a", "b"], ["e"]].
(C) TRUE
(D) FALSE

Y

Yami Thakur • 9.05K Points
Tutor III

Q. What is the output of the given ruby code?

Code:
array = [100, 200, 300, 400, 500]
print array[5]
(A) 500
(B) Syntax Error
(C) Nil
(D) Name Error

Y

Yami Thakur • 9.05K Points
Tutor III

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

Code:
a=[1,2,3,4,5]
b=[1,2,4,6,8]
if a[3]==b[2]
    print Equal
end
(A) TRUE
(B) FALSE
(C) Equal
(D) error

Login

Forgot username? click here

Forgot password? Click here

Don't have account? Register here.