Bird
0
0

Why does Ruby treat even classes themselves as objects?

hard📝 Conceptual Q10 of 15
Ruby - Basics and Runtime
Why does Ruby treat even classes themselves as objects?
ABecause classes are instances of Class, allowing methods on classes
BBecause classes are primitive types without methods
CBecause classes are just strings internally
DBecause classes cannot have methods called on them
Step-by-Step Solution
Solution:
  1. Step 1: Understand Ruby's object model for classes

    In Ruby, classes are themselves objects, instances of the Class class, so they can have methods called on them.
  2. Step 2: Analyze options

    Because classes are instances of Class, allowing methods on classes correctly explains this behavior, while others are incorrect.
  3. Final Answer:

    Because classes are instances of Class, allowing methods on classes -> Option A
  4. Quick Check:

    Classes are objects too, instances of Class [OK]
Quick Trick: Classes are objects, instances of Class class [OK]
Common Mistakes:
MISTAKES
  • Thinking classes are primitive types
  • Believing classes are strings internally
  • Assuming classes cannot have methods

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes