Mastering Java: The Ultimate Quiz for 'Thinking in Java'

Disable ads (and more) with a membership for a one time $2.99 payment

Prepare for your Java exam with our ultimate quiz based on 'Thinking in Java'. Engage with expertly crafted questions that enhance your learning process. Perfect for Java enthusiasts looking to solidify their knowledge!

Each practice test/flash card set has 50 randomly selected questions from a bank of over 500. You'll get a new set of questions each time!

Practice this question and more.


Which of the following is NOT a way to grant access to a class member?

  1. Making the member public

  2. Using the default package access

  3. Declaring the class member as static

  4. Providing accessor/mutator methods

The correct answer is: Declaring the class member as static

One way to grant access to a class member is by making it public, meaning other classes and methods can access it. B is incorrect because using the default package access can grant access to a class member within the same package. D is incorrect because providing accessor/mutator methods allows other classes to modify or retrieve the value of a private class member. C is incorrect because declaring a class member as static has no impact on granting access to it. Static simply means the member belongs to the class rather than to an instance of the class.