Choosing the right visibility for methods and properties - public, private or protected

choosing the right visibility

Use this decision-making process chart to choose the correct visibility for your methods (functions) and properties (variables). Use the following access modifiers:

  1. public - default behavior when it is not specified
  2. private - visible inside original class
  3. protected - same as private, but it can also be accessed by children


Visit sunny St. George, Utah, USA