Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

Salesforce Plat-Dev-201 Exam - Topic 2 Question 14 Discussion

A developer creates a custom exception as shown below:public class ParityException extends Exception { }What are two ways the developer can fire the exception in Apex?
A) throw new ParityException (); and B) throw new parityException ('parity does not match');
C) new ParityException ();
D) new ParityException('parity does not match');

Salesforce Plat-Dev-201 Exam - Topic 2 Question 14 Discussion

Actual exam question for Salesforce's Plat-Dev-201 exam
Question #: 14
Topic #: 2
[All Plat-Dev-201 Questions]

A developer creates a custom exception as shown below:

public class ParityException extends Exception { }

What are two ways the developer can fire the exception in Apex?

Show Suggested Answer Hide Answer
Suggested Answer: A, B

Throwing Exceptions in Apex:

throw new ExceptionType();creates a new instance and throws it.

A: No argument constructor.

B: Constructor with a custom error message.

Why Not Other Options?

C and D: These create exception instances but do not throw them, which is not valid syntax for firing an exception.


Contribute your Thoughts:

0/2000 characters
Madelyn
2 days ago
A is definitely right, but B seems off.
upvoted 0 times
...
Susana
8 days ago
I think A and D are correct.
upvoted 0 times
...
Leonardo
13 days ago
Totally agree with A) and B), those are the right calls!
upvoted 0 times
...
Laquita
18 days ago
Wait, can you really throw a custom exception like that?
upvoted 0 times
...
Carlee
23 days ago
D) seems off, you can't just create it without throwing.
upvoted 0 times
...
Micheline
28 days ago
I think C) is also valid, just not throwing it.
upvoted 0 times
...
Fausto
1 month ago
A) and B) are correct ways to throw it!
upvoted 0 times
...
Emily
1 month ago
I thought you could only throw exceptions with the `throw` keyword, so B seems off to me.
upvoted 0 times
...
Dino
1 month ago
I practiced similar questions, and I feel like A and D are the right answers since they both involve throwing the exception.
upvoted 0 times
...
Eliseo
2 months ago
I'm not entirely sure, but I think C and D are just creating an instance without throwing it, right?
upvoted 0 times
...
Rose
2 months ago
I remember that to throw an exception, we need to use the `throw` keyword, so A looks correct.
upvoted 0 times
...

Save Cancel