Which of the following statement is true about public and private members in…

2024

Which of the following statement is true about public and private members in Java?

Answer: D. Public members can be accessed from any other class.Public members can be accessed from other classes where visibility rules allow it, while private members are restricted to the declaring class.

  1. A.

    Private members can be accessed from any other class.

  2. B.

    Private members can be accessed from subclasses.

  3. C.

    Public members can only be accessed within the same class.

  4. D.

    Public members can be accessed from any other class.

  5. E.

    Question not attempted

Attempted by 307 students.

Show answer & explanation

Correct answer: D

Public members can be accessed from other classes where visibility rules allow it, while private members are restricted to the declaring class.

Explore the full course: Rssb Basic Computer Instructor

Loading lesson…