Home / Programming Questions / Ruby MCQs / Page 14

Ruby MCQs with answers Page - 14

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 is the output of the given ruby code?

Code:
array1 = [[1,2,3,4],[0,0,0,0]]
array2 = [[1,2,3,4],[0,0,0,0]]
print array1-array2
(A) [[1, 2, 3, 4], [0, 0, 0, 0]]
(B) [[1, 2, 3, 4], [0, 0, 0, 0], [1, 2, 3, 4], [0, 0, 0, 0]]
(C) []
(D) Nil

Y

Yami Thakur • 9.05K Points
Tutor III

Q. What is the output of the given code?

Code:
array1 = [[1,2,3,4,5],[0,0,0,0]]
print !array1
(A) Error
(B) [[1, 2, 3, 4, 5], [0, 0, 0, 0]].
(C) TRUE
(D) FALSE

M

Mr. Dubey • 51.17K Points
Coach

Q. Which of the following is not correct method class IO provides?

(A) readline
(B) gets
(C) puts
(D) Writeline

M

Mr. Dubey • 51.17K Points
Coach

Q. What will be output for the following code?

Code:
val1 = ""This is variable one""
puts ""val1""
(A) This is variable one
(B) VAL1
(C) This is variable one val1
(D) val1

M

Mr. Dubey • 51.17K Points
Coach

Q. Which statement can be used to take any input from the user from standard screen?

(A) gets
(B) puts
(C) read
(D) write

M

Mr. Dubey • 51.17K Points
Coach

Q. What will be output for the following code?

Code:
str = ""Hello Ruby!""
putc str
(A) Hello Ruby!
(B) H
(C) R
(D) Hello

M

Mr. Dubey • 51.17K Points
Coach

Q. What is the syntax to close file in ruby?

(A) File.close()
(B) close.File
(C) File.close
(D) close.File()

M

Mr. Dubey • 51.17K Points
Coach

Q. What is the syntax to open file in ruby?

(A) File.open("filename", "mode")
(B) File.open("filename")
(C) File.open()
(D) All of the above

Login

Forgot username? click here

Forgot password? Click here

Don't have account? Register here.