New Year Sale 2026! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

Salesforce Certified Platform Developer II (Plat-Dev-301) Exam - Topic 4 Question 115 Discussion

Actual exam question for Salesforce's Salesforce Certified Platform Developer II (Plat-Dev-301) exam
Question #: 115
Topic #: 4
[All Salesforce Certified Platform Developer II (Plat-Dev-301) Questions]

A developer created a Lightning web component for the Account record page that displays the five most recently contacted Contacts for an Account. The Apex method,

Contacts, returns a list of Contacts and will be wired to a property in the component.

Which two lines must change in the above code to make the Apex method able to be wired?

Choose 2 answers

Show Suggested Answer Hide Answer
Suggested Answer: A, B

To make an Apex method callable from a Lightning Web Component, you need to annotate the method with @AuraEnabled and mark it as cacheable if it's only retrieving data without modifying it. Additionally, the method must be public to be accessible from the component.

Line 04: Needs @AuraEnabled(cacheable=true) to allow the method to be called from the Lightning Web Component and indicate that the method doesn't modify any data, making it suitable for caching.

Line 09: The method getFiveMostRecent should not be private because private methods cannot be called from a Lightning Web Component. Changing it to public (or default, which is equivalent to public within the same namespace) is required.


Lightning Web Components and Salesforce Data: Developer Documentation

@AuraEnabled Annotation: Apex Developer Guide

Contribute your Thoughts:

0/2000 characters
Jenelle
2 months ago
Wait, can you really wire a private method? Seems off.
upvoted 0 times
...
Tomoko
2 months ago
I think removing private is also necessary.
upvoted 0 times
...
Karma
3 months ago
Definitely need to add @AuraEnabled to make it work.
upvoted 0 times
...
Vallie
3 months ago
Adding public to line 04 is a must!
upvoted 0 times
...
Keva
3 months ago
I disagree, I don't think line 09 needs to change at all.
upvoted 0 times
...
Ruthann
3 months ago
I’m a bit confused about whether the cacheable attribute goes on line 03 or 08. I need to double-check that part!
upvoted 0 times
...
Francis
3 months ago
This question feels familiar; I think we practiced something similar where we had to adjust the cacheable attribute.
upvoted 0 times
...
Shakira
4 months ago
I'm not entirely sure, but I think we might need to change the access modifier to public for the method to be wired correctly.
upvoted 0 times
...
Tonette
4 months ago
I remember we discussed the importance of using @AuraEnabled for Apex methods to make them accessible to Lightning components.
upvoted 0 times
...
Cassi
4 months ago
This seems straightforward. I'd start by adding the @AuraEnabled {cacheable=true} annotation to the Apex method, and then removing the private modifier from the property in the component.
upvoted 0 times
...
Cordie
4 months ago
I'm not entirely sure about this one. I'll need to double-check the documentation on wiring Apex methods to Lightning web components.
upvoted 0 times
...
Refugia
4 months ago
Okay, I think I've got it. The two lines that need to change are adding @AuraEnabled {cacheable=true} to the Apex method, and removing the private modifier from the property in the component.
upvoted 0 times
...
Stefania
5 months ago
Hmm, I'm a bit confused about the difference between @AuraEnabled and @AuraEnabled {cacheable=true}. I'll need to review that before answering.
upvoted 0 times
...
Johnetta
5 months ago
This looks like a pretty straightforward question. I think the key is to identify the lines that need to be changed to make the Apex method wirable.
upvoted 0 times
...
Carin
7 months ago
This question is a piece of cake. I bet the developers who wrote this code are still trying to figure out how to make it work.
upvoted 0 times
Launa
5 months ago
B) Remove private from line 09.
upvoted 0 times
...
Burma
6 months ago
A) Add @AuraEnabled {cacheable=true) to line 03.
upvoted 0 times
...
...
Shawnta
7 months ago
Haha, I love how they're trying to trick us with the 'private' modifier. Nice try, but we know better!
upvoted 0 times
Hobert
7 months ago
B) Remove private from line 09.
upvoted 0 times
...
Elroy
7 months ago
A) Add @AuraEnabled {cacheable=true) to line 03.
upvoted 0 times
...
...
Micah
8 months ago
I'm not sure, I think we also need to remove private from line 09.
upvoted 0 times
...
Judy
8 months ago
I agree with Alexia, that seems like the right change to make.
upvoted 0 times
...
Alexia
8 months ago
I think we need to add @AuraEnabled {cacheable=true) to line 03.
upvoted 0 times
...
Jacob
8 months ago
I agree with Rebbecca. Removing the private modifier and adding public won't work because the method is still not @AuraEnabled.
upvoted 0 times
Terrilyn
8 months ago
B) Remove private from line 09.
upvoted 0 times
...
Erinn
8 months ago
A) Add @AuraEnabled {cacheable=true) to line 03.
upvoted 0 times
...
...
Rebbecca
9 months ago
A and D are the correct answers. The Apex method needs to be marked as @AuraEnabled and cacheable=true to be wired to the component.
upvoted 0 times
Lucy
8 months ago
A) Add @AuraEnabled {cacheable=true) to line 03.
upvoted 0 times
...
Edelmira
8 months ago
D) Add @AuraEnabled {cacheable=true) to line 03.
upvoted 0 times
...
Laurel
8 months ago
Thanks for the info!
upvoted 0 times
...
Shannan
8 months ago
B) Remove private from line 09.
upvoted 0 times
...
Junita
8 months ago
A) Add @AuraEnabled {cacheable=true) to line 03.
upvoted 0 times
...
...

Save Cancel