Scenario: I have 1 APEX class, in which I have inner class extending exception, as can be seen below:

public with sharing class ClassA{
   PUBLIC/PRIVATE class ClassBException extends ClassCException {}

This ClassBException is only used for ClassA, and ClassA will in turn be used in LWC.

Question: The access modifier where it is in all caps in above code (PUBLIC/PRIVATE) should be public or private?

Note: this developer guide only talks about method or variable but what about the inner classes especially the exception classes.

1 Answer 1


From a strictly Object-Oriented Programming perspective, it should be private (which, you can also just omit, as private is the default access). This makes it clear to future code readers/maintainers that this class is only used locally. Functionally speaking, it doesn't matter which access you provide if you only intend to use it in ClassA.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .