Bird
0
0

Which of the following is true about methods added by include in Ruby?

easy📝 Conceptual Q2 of 15
Ruby - Modules and Mixins
Which of the following is true about methods added by include in Ruby?
AThey become private methods of the class
BThey become instance methods of the class
CThey become singleton methods of the module
DThey become class methods of the class
Step-by-Step Solution
Solution:
  1. Step 1: Recall what include does

    It mixes in the module's instance methods as instance methods of the including class.
  2. Step 2: Understand method visibility

    By default, included methods are public instance methods, not private or class methods.
  3. Final Answer:

    They become instance methods of the class -> Option B
  4. Quick Check:

    Include = instance methods [OK]
Quick Trick: Include adds public instance methods by default [OK]
Common Mistakes:
  • Assuming included methods become private
  • Confusing instance and class methods
  • Thinking methods become singleton methods

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes