222k views
2 votes
Encapsulation means ________. 1. that data fields should be declared private2. that a class can extend another class 3. that a variable of supertype can refer to a subtype object 4. that a class can contain another class

User Docmurloc
by
3.7k points

1 Answer

3 votes

Answer:

Option 1 is the correct answer for the above question.

Step-by-step explanation:

Encapsulation means rapper the data or variable or method on some pack and denies to give direct access for any private data. The above question wants to ask about the Encapsulation. The option 1 is correct for its because this option suggests a scenario, where a class field is declared as private and we know that private data members of the class can not be accessed by outside the class. It can access only the inside of the class. So it proves both the property of encapsulation one is to rapper the data and the other is to deny the directly accessed outside. So this option is correct while the other is not because--

  • Option 2 states that another class is extended by the base class which is not the property of encapsulation.
  • Option 3 states that a sub-type object can be referred by the variable of super-type which is also not the property of encapsulation.
  • Option 4 states that a class is contained by the other class which does not hold both the property of encapsulation.
User Alimin
by
3.1k points