Computer Science, asked by Qamar5005, 7 months ago

Which of the following statements are incorrect? (A) public members of class can be accessed by any code in the program (B) private members of class can only be accessed by other members of the class (C) private members of class can be inherited by a subclass, and become protected members in subclass (D) protected members of a class can be inherited by a subclass, and become private members of the subclass

Answers

Answered by mtahir27
7

Answer:

b) is the incorrect statment.

Answered by adventureisland
0

Option (C) is correct.

(C) Private members of the class can be inherited by a subclass, and become protected members in subclass

About Access modifiers :

  • The visibility of a class, variable, function and function Object() may all be controlled using access modifiers. Non-access modifiers, on the other hand, are used to provide extra functionality to a method or block, such as synchronizing it or limiting the serialization of a variable.

Public :

  • Any statement in the program can access the public members of a class.

Private :

  • Only the class in which the private methods and data members are specified can access them. Any other class in the same package won't be able to access these members.

Protected :

  • Only through inheritance may the protected access modifier be used both within and outside of the package. The protected access modifier can be added to all data members, methods, and functions in the Object() class.

Similar questions