Public:
When you declare a method [function] or a property [variable] as public
, those methods and properties can be accessed by:
- The same class that declared it.
- The classes that inherit the above declared class.
- Any foreign elements outside this class can also access those things.
Example: