Important Java Mcq 1

Which statement is not true in the Java language?

a. A public member of a class can be accessed in all the packages.

b. A private member of a class cannot be accessed by all the methods of the same
class.

c. A private member of a class cannot be accessed from its derived class.

d. A protected member of a class can be accessed from its derived class.

Answer:

b. A private member of a class cannot be accessed by all the methods of the same
class.

Explanation

The ‘private’ members of a class are not accessible anywhere outside the class.
They are accessible only within the class by the methods of that class.

Related MCQs
Aniket Malik

Aniket Malik

CERTIFIED TUTOR/TRAINER WITH 300+ REVIEWS

Facing difficulty with

this concept?