Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.
exam questions

Exam CRT-450 All Questions

View all questions & answers for the CRT-450 exam

Exam CRT-450 topic 1 question 164 discussion

Actual exam question from Salesforce's CRT-450
Question #: 164
Topic #: 1
[All CRT-450 Questions]

Which three statements are true regarding custom exceptions in Apex? (Choose three.)

  • A. A custom exception class must extend the system Exception class.
  • B. A custom exception class can implement one or many interfaces.
  • C. A custom exception class cannot contain member variables or methods.
  • D. A custom exception class name must end with ג€Exceptionג€.
  • E. A custom exception class can extend other classes besides the Exception class.
Show Suggested Answer Hide Answer
Suggested Answer: ABD 🗳️

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
Pally88
Highly Voted 3 years, 4 months ago
D not E
upvoted 6 times
...
noox
Highly Voted 2 years, 10 months ago
Selected Answer: ABD
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_exception_custom.htm "To create your custom exception class, extend the built-in Exception class and make sure your class name ends with the word Exception, such as “MyException” or “PurchaseException”."
upvoted 6 times
...
Nand072
Most Recent 1 year, 2 months ago
Selected Answer: ABD
how the hell could E be correct! Come on!
upvoted 1 times
...
1vanTT
1 year, 5 months ago
Selected Answer: ABD
Technically a custom exception class can extend another class that itself extends the System extension class, so you could argue that E could also be correct, but if its a toss up between D and E, I'd say D is "more" correct
upvoted 3 times
...
govosen887
1 year, 7 months ago
Selected Answer: ABD
A, B, D - easy to get by elimination even if you're not certain about D (C contradicts B and E, E is false due to lack of multiple inheritance in Apex)
upvoted 1 times
...
Sasi7
1 year, 8 months ago
While options A and B are agreed upon as the correct answers, there seems to be confusion among people on whether to choose option D or E as the third correct answer. Here's my take. Both options D and E are partially correct, but option E is the more accurate choice as a third correct answer. Here's why, Option D states that a custom exception class name must end with "Exception", which is not entirely true. While it is common to name custom exceptions with the "Exception" suffix, it is not a strict requirement. Option E, on the other hand, states that a custom exception class can extend other classes besides the Exception class, which is true. Custom exception classes can indeed extend other classes or implement interfaces, allowing for greater flexibility in handling exceptions.
upvoted 3 times
govosen887
1 year, 7 months ago
Multiple inheritance is not allowed in Apex - you can implement many interfaces but not extend many classes (well, unless you want to argue that Exception extends Object so it's two classes extended...)
upvoted 1 times
...
edogaldo
1 year, 2 months ago
I also thought that D was a best practice and not a requirement but instead it is! If you try to create a custom exception class whose name does not terminate with "Exception" you will get compile error: "Classes extending Exception must have a name ending in Exception: <class_name>"
upvoted 1 times
...
...
ApexMike
2 years, 1 month ago
Selected Answer: ABD
ABD are correct.
upvoted 2 times
...
tapasroy
2 years, 7 months ago
Seems ABE options are correct. D is not correct, since you can name the class anything and without 'exception' in it. Only thing is that it should extend from exception class.
upvoted 1 times
ApexMike
2 years, 1 month ago
Nope. exception classes has to end with the word Exception. It won't compile otherwise. https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_exception_custom.htm
upvoted 4 times
...
...
JCTheGenius
3 years, 2 months ago
I agree: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_exception_custom.htm
upvoted 2 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...