Bird
0
0

Which of the following is the correct syntax to convert a string name to uppercase in Ruby?

easy📝 Syntax Q3 of 15
Ruby - String Operations
Which of the following is the correct syntax to convert a string name to uppercase in Ruby?
Aupcase(name)
Bname.upcase()
Cname.toUpperCase()
Dname.upper()
Step-by-Step Solution
Solution:
  1. Step 1: Recall Ruby method syntax for strings

    In Ruby, string methods are called with dot notation, like name.upcase().
  2. Step 2: Identify invalid options

    upcase(name) is not Ruby syntax, toUpperCase() is JavaScript, and upper() is not a Ruby method.
  3. Final Answer:

    name.upcase() -> Option B
  4. Quick Check:

    Correct Ruby method call = name.upcase() [OK]
Quick Trick: Use dot notation: string.method() in Ruby [OK]
Common Mistakes:
MISTAKES
  • Using JavaScript syntax
  • Calling method without dot
  • Using wrong method names

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes