Bird
0
0

Find the error in this Ruby code:

medium📝 Debug Q6 of 15
Ruby - Basics and Runtime
Find the error in this Ruby code:
puts "Hello"
print "World"
p Hello
AMissing quotes around Hello in p method
Bprint should be print()
Cputs cannot print strings
Dp cannot be used with strings
Step-by-Step Solution
Solution:
  1. Step 1: Check syntax of p method call

    p Hello is invalid because Hello is not defined as a variable or string; it needs quotes.
  2. Step 2: Verify other lines

    puts "Hello" and print "World" are correct syntax.
  3. Final Answer:

    Missing quotes around Hello in p method -> Option A
  4. Quick Check:

    p requires valid object or string argument = B [OK]
Quick Trick: Always quote strings when passing to p [OK]
Common Mistakes:
  • Forgetting quotes around strings
  • Thinking print needs parentheses
  • Assuming puts can't print strings

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes