Grokking Java Intermediate
0% completed
Access Modifiers and Inheritance
When a subclass inherits from a superclass, the members of the superclass (fields, methods) remain subject to their original access modifiers. These modifiers control which members the subclass can see, as well as what’s visible to other classes inside or outside the package. Choosing the right access modifier helps maintain both security (encapsulation) and flexibility.
How Do Access Modifiers Work With Subclasses?
- private:
- Visible only inside the declaring class.
- Subclasses cannot access it directly.
- Other classes cannot access it directly.
.....
.....
.....
Like the course? Get enrolled and start learning!
Reading Progress
0%