Bird
0
0

What does Class.new do in Ruby?

easy📝 Conceptual Q11 of 15
Ruby - Metaprogramming Fundamentals
What does Class.new do in Ruby?
ADefines a method inside a class
BDeletes an existing class
CCreates a new instance of a class
DCreates a new class dynamically at runtime
Step-by-Step Solution
Solution:
  1. Step 1: Understand the purpose of Class.new

    Class.new is used to create a new class dynamically while the program runs, without writing a full class definition.
  2. Step 2: Differentiate from other options

    It does not delete classes, create instances, or define methods alone. It creates a new class object.
  3. Final Answer:

    Creates a new class dynamically at runtime -> Option D
  4. Quick Check:

    Class.new = dynamic class creation [OK]
Quick Trick: Class.new always creates a new class object [OK]
Common Mistakes:
  • Confusing class creation with instance creation
  • Thinking it deletes or modifies existing classes
  • Assuming it only defines methods

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes