Bird
0
0

Which of the following is the correct syntax to define a constant named MAX_SPEED with value 100 inside a Ruby class?

easy📝 Syntax Q3 of 15
Ruby - Class Methods and Variables
Which of the following is the correct syntax to define a constant named MAX_SPEED with value 100 inside a Ruby class?
Adef MAX_SPEED; 100; end
Bmax_speed = 100
Cconst MAX_SPEED = 100
DMAX_SPEED = 100
Step-by-Step Solution
Solution:
  1. Step 1: Identify Ruby constant naming rules

    Constants start with an uppercase letter and are assigned with =.
  2. Step 2: Check syntax options

    Only 'MAX_SPEED = 100' matches Ruby constant syntax.
  3. Final Answer:

    MAX_SPEED = 100 -> Option D
  4. Quick Check:

    Constant syntax = uppercase name + = [OK]
Quick Trick: Constants start with uppercase letters and use = [OK]
Common Mistakes:
  • Using lowercase names for constants
  • Trying to use 'const' keyword (not Ruby)
  • Defining constants as methods

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes