Question: If you forget to code an access modifier on a class variable (that is, you dont code public, protected, or private), Java assigns the variable

  1. If you forget to code an access modifier on a class variable (that is, you dont code public, protected, or private), Java assigns the variable package access which opens it up to modification from any class in the same package as the class that contains the unmodified variable. Most programmers consider this a bad idea as it breaks the object-oriented principle of data encapsulation. This insidious effect occurs when you are forgetful and leave off the access modifier accidentally. For that reason, you need to be aware of this default behavior in case you are careless. Explain how package access variables differ from protected access variables, below.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!