You need to sign in to do that
Don't have an account?

protected vs. private
could someone tell me (in English :) ) what the functional difference is between these two access modifiers? from what I see, they both prevent access from outside classes, but what else? what are the benefits of one vs. the other?
Protected allows access in sub classes. So if you have a Vehicle class with a protected variable called colour, a Car class that extended Vehicle could operate on the colour variable. If the variable was private, you wouldn't be able to access it.
From the documentation:
private
protected
This means that the method or variable is visible to any inner classes in the defining Apex class, and to the classes that extend the defining Apex class. You can only use this access modifier for instance methods and member variables. Note that it is strictly more permissive than the default (private) setting, just like Java.
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_access_modifiers.htm