What are access modifiers and what are they ?

686    Asked by EllaClarkson in Salesforce , Asked on Feb 21, 2020
Answered by Ella Clarkson

How a member of class can be accessed is determined by the access modifiers attached to it's declaration.

The access modifiers are public, private and protected.

So now let's define the public first, when a member of a class is modified by the public then that member can be accessed by any other code.

Private:-

When a member of a class is modified by private then that member can only be accessed by other members of it's class.

Protected:-

It applies only when inheritance is involved.



Your Answer

Interviews

Parent Categories