Ruby MCQs On Variables

This section focuses on "Variables" in Ruby. These Multiple Choice Questions (MCQ) should be practiced to improve the Ruby skills required for various interviews (campus interviews, walk-in interviews, company interviews), placements, entrance exams and other competitive examinations.

1. Global variables in ruby begin with?

A. @
B. #
C. $
D. &

View Answer


2. Default value of global variable is?

A. -1
B. nil
C. 1
D. infinite

View Answer


3. Local variables in ruby begin with?

A. @
B. _
C. *
D. #

View Answer


4. Which of the following Ruby Pseudo-Variables is used for The receiver object of the current method?

A. self
B. current
C. nil
D. _FILE_

View Answer


5. Which of the following Ruby Pseudo Variables is used to return current line number in the source file?

A. _FILE_
B. _CURRENT_
C. _LINE_
D. None of the above

View Answer


6. Which notation is used for Octal notation?

A. \s
B. \xnn
C. \n
D. \nn

View Answer


7. Which of the following datatypes are valid in Ruby?

A. Numbers
B. String
C. Boolean
D. All of the above

View Answer


8. What is the sequence of ruby strings?

A. 16-bit bytes
B. 8-bit bytes
C. 4-bit bytes
D. None of the above

View Answer


9. single-quoted strings don`t allow ?

A. substitution
B. backslash notation
C. single-quoted strings allow substitution and backslash notation.
D. single-quoted strings don`t allow substitution and allow backslash notation.

View Answer


10. Objects of which class does the integer from the range -2^60 to 2^(60-1) belong to?

A. Octal
B. Bignum
C. Fixnum
D. Binary

View Answer





Discussion


* You must be logged in to add comment.