Ask Question
15 August, 08:43

Which of the following statements is true? a. Most instance-variable declarations are preceded with the keyword public, which is an access modifier b. Each object (instance) of the class shares the class's instance variables c. Variables or methods declared with access modifier private are accessible only to methods of the class in which they're declared d. None of these statements is true

+1
Answers (1)
  1. 15 August, 09:50
    0
    Answer: c) Variables or methods declared with access modifier private are accessible only to methods of the class in which they're declared.

    Explanation: Private access modifier behaves in the restrictive way at the class level. For object encapsulation for hiding the information, private access modifier is used. The classes can't be declared as private in this case. Thus, variables that get declaration through private access modifier can be accessed by class containing the same method in which they got declared.

    Other options are incorrect because not most variables get declared with public keyword and class instances are not shared by every object of class. Thus, the correct option is option (c).
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Which of the following statements is true? a. Most instance-variable declarations are preceded with the keyword public, which is an access ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers