Ruby MCQ On Operators

This section focuses on "Operators" 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. Which of the following is not type of operator in ruby?

A. Arithmetic Operators
B. Comparison Operators
C. Similar operator
D. Parallel Assignment

View Answer


2. eql? Operator is used for?

A. Used to test equality within a when clause of a case statement.
B. if the receiver and argument have both the same type and equal values.
C. if the receiver and argument have the same object id.
D. All of the above

View Answer


3. Which of the following is not a type of Bitwise Operators?

A. <<
B. ^
C. ~
D. None of the above

View Answer


4. In range operator ... is used for ?

A. Creates a range from start point to end point inclusive.
B. Creates a range from start point to end point exclusive.
C. Creates a range from start point inclusive to end point exclusive.
D. Creates a range from start point exclusive to end point inclusive.

View Answer


5. Among the following which operator has highest Precedence?

A. ::
B. .
C. []
D. **

View Answer


6. What will be the output of the given code?

boolean_var = 15 < 16 && 15 < 15
puts boolean_var

A. TRUE
B. FALSE
C. Type Error
D. Syntax Error

View Answer


7. What will be the output of the given code?

num=4>>2
puts num

A. -2
B. 0
C. 2
D. 1

View Answer


8. What will be the output of the given code?

boolean_var = 3**2 != 2**3 || true
puts boolean_var

A. TRUE
B. FALSE
C. 1
D. 0

View Answer


9. What will be the output of the given code?

 boolean_var = !(100 / 10 === 10)
puts boolean_var

A. TRUE
B. FALSE
C. Type Error
D. Syntax Error

View Answer


10. What will the following expression evaluate to?

true || false

A. TRUE
B. FALSE
C. Syntax Error
D. None of the above

View Answer





Discussion


* You must be logged in to add comment.