Ruby MCQs with answers Page - 6

Here, you will find a collection of MCQ questions on Ruby. Go through these questions to enhance your preparation for upcoming examinations and interviews.

To check the correct answer, simply click the View Answer button provided for each question.

Have your own questions to contribute? Click the button below to share your MCQs with others!

+ Add Question

A

Admin • 802.91K Points
Coach

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

Code:
num=4>>2
puts num
  • (A) -2
  • (B) 0
  • (C) 2
  • (D) 1

A

Admin • 802.91K Points
Coach

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

Code:
num=(10<11)||(11===11)? (11===11.0): 0
puts num
  • (A) TRUE
  • (B) FALSE
  • (C) 1
  • (D) 0

A

Admin • 802.91K Points
Coach

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

Code:
boolean_var = !true || (true || 36 != 6**2)
puts boolean_var
  • (A) TRUE
  • (B) FALSE
  • (C) Error
  • (D) None of the above

A

Admin • 802.91K Points
Coach

Q. What will the following expression evaluate to?

Code:
true || false
  • (A) TRUE
  • (B) FALSE
  • (C) Syntax Error
  • (D) None of the above

A

Admin • 802.91K Points
Coach

Q. Which of the following is not a type of loop in ruby?

  • (A) For Loop
  • (B) Foreach Loop
  • (C) Until Loop
  • (D) While Loop

A

Admin • 802.91K Points
Coach

Q. What is true about Until loop?

  • (A) Executes code while conditional is true
  • (B) In until loop increment is not required
  • (C) Executes code while conditional is false
  • (D) None of the above

A

Admin • 802.91K Points
Coach

Q. What is true about while loop?

  • (A) Executes code while conditional is true
  • (B) In while loop increment is not required
  • (C) Executes code while conditional is false
  • (D) None of the above

A

Admin • 802.91K Points
Coach

Q. What is the use of break statement?

  • (A) Terminates the most External loop.
  • (B) Terminates all loop.
  • (C) Terminates the program.
  • (D) Terminates the most internal loop.

A

Admin • 802.91K Points
Coach

Q. Which statement is used to Jumps to the next iteration of the most internal loop?

  • (A) break
  • (B) next
  • (C) redo
  • (D) retry

A

Admin • 802.91K Points
Coach

Q. Which statement is used to Restarts this iteration of the most internal loop, without checking loop condition?

  • (A) break
  • (B) next
  • (C) redo
  • (D) retry

Add MCQ in this Category

If you want to share an MCQ question in this category, it's a great idea! It will be helpful for many other students using this website.

Share Your MCQ