Public:
These methods can be used from
any methods where the class
is accessible and can
also be overridden by classes that extend this class
(Sub classes). If no
access modifiers are explicitly written in the code, the
Compiler assumes that
they are public and handles them accordingly.
Default behavior for
classes and methods. A public class can be inherited
And class methods can be overridden in sub classes and called outside the
Class.
Protected:
These methods can be used from
any methods in the same class
Or subclass. Only methods can be
protected. A protected method can overridden in
Sub classes, but can only be used inside the class hierarchy
Private:
These methods
can only be used from any methods in the same class
both classes and methods can be set as private. However this will
only affects methods. A private method can only be used within the current class.
No comments:
Post a Comment