Bird
0
0

What will be the output when running this Ruby script with ruby test.rb?

medium📝 Predict Output Q4 of 15
Ruby - Basics and Runtime
What will be the output when running this Ruby script with ruby test.rb?
puts 'Start'
puts 5 + 3
puts 'End'
AStart 5 + 3 End
BError: invalid syntax
CStart 53 End
DStart 8 End
Step-by-Step Solution
Solution:
  1. Step 1: Understand the script output

    The script prints 'Start', then the result of 5 + 3 (which is 8), then 'End'.
  2. Step 2: Confirm output formatting

    Each puts prints on a new line, so output lines are 'Start', '8', 'End'.
  3. Final Answer:

    Start 8 End -> Option D
  4. Quick Check:

    puts with expression = evaluated output [OK]
Quick Trick: puts prints evaluated expressions line by line [OK]
Common Mistakes:
MISTAKES
  • Expecting expression as string
  • Concatenating numbers as strings
  • Thinking it causes syntax error

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes