Important Java Mcq 1

Which statement is true about the accessibility of members?

a. private members are always accessible from within the same package.

b. private members can only be accessed by code from within the class of the member

c. package/default accessibility for a member can be declared using the keyword default.

d. private members cannot be accessed at all

Answer:

b. private members can only be accessed by code from within the class of the member

Explanation

A private member of a class is not accessible anywhere outside the class.
If no access modifier has been specified, a member has default accessibility, also known as
package accessibility. Subclass outside the package cannot access members with default
accessibility.

Related MCQs
Aniket Malik

Aniket Malik

CERTIFIED TUTOR/TRAINER WITH 300+ REVIEWS

Facing difficulty with

this concept?