Bird
0
0

Which syntax correctly calls the method 'upcase' on a string in Ruby?

easy📝 Syntax Q3 of 15
Ruby - Classes and Objects
Which syntax correctly calls the method 'upcase' on a string in Ruby?
A"hello".upcase
Bupcase("hello")
C"hello"->upcase
Dhello.upcase()
Step-by-Step Solution
Solution:
  1. Step 1: Recall method call syntax in Ruby

    Methods are called on objects using dot notation: object.method.
  2. Step 2: Check each option

    "hello".upcase uses correct syntax "hello".upcase. upcase("hello") is wrong syntax, A uses invalid arrow, D misses quotes around string.
  3. Final Answer:

    "hello".upcase -> Option A
  4. Quick Check:

    Method call syntax = C [OK]
Quick Trick: Use dot notation to call methods on objects [OK]
Common Mistakes:
  • Using function call style instead of dot notation
  • Missing quotes around string literals
  • Using invalid symbols like arrows for method calls

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes