Ask Question
6 February, 10:58

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

+4
Answers (1)
  1. 6 February, 11:06
    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?
Find 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 the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers