πŸ“Š Ruby
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
πŸ’¬ Discuss
βœ… Correct Answer: (B) Foreach Loop

Explanation: Foreach loop is not there in ruby.

πŸ“Š Ruby
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
πŸ’¬ Discuss
βœ… Correct Answer: (C) Executes code while conditional is false

Explanation: Executes code while conditional is false. An until statement`s conditional is separated from code by the reserved word do, a newline, or a semicolon.

πŸ“Š Ruby
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
πŸ’¬ Discuss
βœ… Correct Answer: (A) Executes code while conditional is true

Explanation: Executes code while conditional is true. A while loop`s conditional is separated from code by the reserved word do, a newline, backslash , or a semicolon.

πŸ“Š Ruby
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.
πŸ’¬ Discuss
βœ… Correct Answer: (D) Terminates the most internal loop.

Explanation: Terminates the most internal loop. Terminates a method with an associated block if called within the block (with the method returning nil).

πŸ“Š Ruby
Q. Which statement is used to Jumps to the next iteration of the most internal loop?
  • (A) break
  • (B) next
  • (C) redo
  • (D) retry
πŸ’¬ Discuss
βœ… Correct Answer: (B) next

Explanation: Next : Jumps to the next iteration of the most internal loop. Terminates execution of a block if called within a block

πŸ“Š Ruby
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
πŸ’¬ Discuss
βœ… Correct Answer: (C) redo

Explanation: Redo : Restarts this iteration of the most internal loop, without checking loop condition. Restarts yield or call if called within a block.

πŸ“Š Ruby
Q. Which statement is used to restarts the invocation of the iterator call?
  • (A) break
  • (B) next
  • (C) redo
  • (D) retry
πŸ’¬ Discuss
βœ… Correct Answer: (D) retry

Explanation: If retry appears in the iterator, the block, or the body of the for expression, restarts the invocation of the iterator call. Arguments to the iterator is re-evaluated.

πŸ“Š Ruby
Q. What does the 1..5 indicate?
  • (A) Exclusive range
  • (B) Both inclusive and exclusive range
  • (C) Inclusive range
  • (D) None of the above
πŸ’¬ Discuss
βœ… Correct Answer: (C) Inclusive range

Explanation: 1..5 means start from one and go till 4 and even include 5.

πŸ“Š Ruby
Q. What does end represent?
  • (A) keyword represents the ending of loop
  • (B) keyword represents the start of loop
  • (C) keyword represents the start and ending of loop
  • (D) keyword represents the infinite loop
πŸ’¬ Discuss
βœ… Correct Answer: (A) keyword represents the ending of loop

Explanation: end: This keyword represents the ending of 'for' loop block which started from 'do' keyword.

πŸ“Š Ruby
Q. Which of the following is Exit Controlled loop?
  • (A) do..while
  • (B) For
  • (C) Until
  • (D) While
πŸ’¬ Discuss
βœ… Correct Answer: (A) do..while

Explanation: do..while is Exit-Controlled loop because it tests the condition which presents at the end of the loop body.