Courseiva

SF-PD2 Advanced Developer Fundamentals Practice Question

A developer is building a Lightning web component that needs to display a list of Accounts with their Contacts. The component should allow users to select an Account and see its Contacts without a full page reload. Which Apex feature should be used to retrieve the Contacts when an Account is selected?

⚠ Common exam trap

Many candidates confuse asynchronous Apex or other API protocols with the standard Apex integration pattern for Lightning web components.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

An @AuraEnabled(cacheable=true) method that queries Contacts by AccountId.

The correct feature is an @AuraEnabled(cacheable=true) Apex method. It allows Lightning web components to retrieve data on demand and supports caching, which is ideal for dynamic user interactions. Other options either cannot return data synchronously, are not compatible with LWC, or introduce unnecessary complexity.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✓

    An @AuraEnabled(cacheable=true) method that queries Contacts by AccountId.

    Why this is correct

    This is correct because @AuraEnabled(cacheable=true) methods are exposed to Lightning web components and can be called imperatively or via wire. They support caching, which improves performance for repeated calls. The method can accept the selected AccountId and return the related Contacts, enabling dynamic updates without a page reload.

  • ✗

    A SOAP API call from the component to the Salesforce endpoint.

    Why it's wrong here

    While SOAP API can retrieve data, calling it directly from a Lightning web component is not standard and would require authentication and handling of the SOAP envelope. It is overly complex and not designed for this use case. Apex methods are the preferred way to expose data to Lightning web components.

  • ✗

    A @future method that queries Contacts and returns them to the component.

    Why it's wrong here

    @future methods are used for asynchronous processing and cannot return data to the caller. They are also not directly callable from Lightning web components. This option would not provide the Contacts to the component in real time, and the asynchronous nature would complicate the user experience.

  • ✗

    A Visualforce controller method invoked via a JavaScript remoting call.

    Why it's wrong here

    Visualforce controllers and JavaScript remoting are part of the Visualforce framework, not Lightning web components. Mixing them is not supported in LWC. This approach would not work because LWC cannot directly invoke Visualforce controller methods. Apex methods are the correct integration point.

About these practice questions

This SF-PD2 question is part of Courseiva's 226-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official Salesforce exam blueprint

This SF-PD2 practice question is part of Courseiva's free Salesforce certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the SF-PD2 exam.