Bird
0
0

Identify the error in this Ruby snippet:

medium📝 Debug Q7 of 15
Ruby - Classes and Objects
Identify the error in this Ruby snippet:
class Test
  def 123method
    puts "Hello"
  end
end
AMissing end keyword for class
BNo error, code is valid
Cputs cannot be used inside methods
DMethod names cannot start with numbers
Step-by-Step Solution
Solution:
  1. Step 1: Recall Ruby method naming rules

    Method names must start with a letter or underscore, not a number.
  2. Step 2: Check the method name

    Method named 123method starts with digits, which is invalid syntax.
  3. Final Answer:

    Method names cannot start with numbers -> Option D
  4. Quick Check:

    Method names must start with letter/underscore = B [OK]
Quick Trick: Method names must start with letter or underscore [OK]
Common Mistakes:
  • Trying to start method names with digits
  • Forgetting to close class with end
  • Thinking puts is invalid inside methods

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes