What are the types of exception classes developers can choose between in Apex?
Click on the arrows to vote for the correct answer
A. B. C. D.A.
The correct answer is A. System-defined, user-defined.
In Apex, an exception is an unexpected event that occurs during the execution of a program. When an exception occurs, the program terminates abnormally and control is transferred to the exception handler. To handle exceptions in Apex, developers can use exception classes.
There are two types of exception classes in Apex:
Example:
javapublic class CustomException extends Exception { public CustomException(String message) { super(message); } }
In this example, a custom exception class named CustomException is created by extending the built-in Apex Exception class. The constructor for the custom exception class takes a message parameter and passes it to the super constructor.
In summary, developers can choose between two types of exception classes in Apex: system-defined and user-defined. System-defined exception classes are provided by Salesforce and can be used to handle various types of exceptions that can occur during the execution of an Apex program. User-defined exception classes are created by developers to handle specific exceptions that may occur during the execution of their Apex program.