Access modifiers is the terinology given to describe the various roles and perimission that a variable within a parent / sub class can have on various places.
Access Modifiers are of 4 types
Public – This would mean that the variable is freely allowed to be used anywhere
Default – This means that the variable / method is allowed freely to be used accessed within the package alone
Private – This means that the variables / methods are allowed only in the parent class and restricted to it. This cannot be accessed outside of the class, even the subclass does not have access to it
Protected – A protected variable / function has access full access to any class as long as they are in the same package or any subclass irrespective of pacakge. 🙂 If you feel confusing, watch out the video below
Comments
Post a Comment