← BYTES
Java·Starter·Ref: 9.1.12
What is the purpose of access modifiers like `private`, `public`, and `protected` in Java?
Have a question about this video? Mention reference 9.1.12 when you contact us.
a.They control the visibility/accessibility of a field, method, or class from other code
b.They control how fast a method runs
c.They determine whether a variable is static
d.They are purely cosmetic with no compiler-enforced effect
Access modifiers are enforced by the compiler to control encapsulation: private is visible only within the same class, protected within the package and subclasses, public everywhere, and (no modifier) package-private within the same package only.
Find this on YouTube & Instagram
Every BYTES video is tagged with its reference number and topic — search any of these on YouTube or Instagram to find this one:
#BYTES#BYTES9112#Java