ICSE Class 10 Computer Applications Question 1 of 17

Encapsulation — Question 4

Back to all questions
4
Question

Question 4

Name various visibility modifiers in a class.

Answer

The various visibility modifiers in a class are as follows:

  1. public — The public members are accessible in all the classes whether a subclass or any other class in same package or another package.
  2. private — The private members are accessible only inside their own class and nowhere else.
  3. protected — The protected members are accessible inside all the classes in their own package as well as in all subclasses of their class.
  4. default — The default members are accessible inside all the classes of the same package.