Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

Ruby%20On%20Rails%20Interview%20Questions%20and%20Answers

Question: What are the three levels of method access control for classes and what do they signify? What do they imply about the method?
Answer:
  • Public, protected, and private.

  • Public methods can be called by all objects and subclasses of the class in which they are defined in.

  • Protected methods are only accessible to objects within the same class.

  • Private methods are only accessible within the same instance.

  • Be able to explain why this does (or doesn’t matter), and when you would want to set a method as private.
Is it helpful? Yes No

Most helpful rated by users:

©2024 WithoutBook