Important Java Mcq 1

How restrictive is the default?

a. Less restrictive than public.

b. More restrictive than public, but less restrictive than protected.

c. More restrictive than protected, but less restrictive than private.

d. More restrictive than private.

Answer:

c. More restrictive than protected, but less restrictive than private

Explanation:

The default accessibility for members is more restrictive than protected accessibility but less restrictive than private. Members with default accessibility are only accessible within the class itself and from classes in the same package. Protected members are in addition accessible from sub-classes anywhere. Members with private accessibility are only accessible within the class itself.

Related MCQs
Aniket Malik

Aniket Malik

CERTIFIED TUTOR/TRAINER WITH 300+ REVIEWS

Facing difficulty with

this concept?