Bird
0
0

Which of the following is true when a module is extended in a Ruby class?

easy📝 Conceptual Q2 of 15
Ruby - Modules and Mixins
Which of the following is true when a module is extended in a Ruby class?
AModule methods become class methods of the class
BModule methods are ignored
CModule methods become instance methods of the class
DModule methods become private methods
Step-by-Step Solution
Solution:
  1. Step 1: Recall effect of extend

    Extending a module adds its methods as class methods to the class.
  2. Step 2: Eliminate incorrect options

    Instance methods come from include, not extend. Methods are not ignored or made private by default.
  3. Final Answer:

    Module methods become class methods of the class -> Option A
  4. Quick Check:

    extend adds class methods = C [OK]
Quick Trick: Extend adds module methods as class methods, not instance methods [OK]
Common Mistakes:
  • Confusing instance vs class methods
  • Assuming methods become private automatically
  • Ignoring the effect of extend

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes