Ask Question
1 December, 12:14

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. 1 December, 14: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?
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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers