Courseiva

SF-PD2 Advanced Developer Fundamentals Practice Question

A developer needs to expose an Apex method so that a Lightning web component can call it and receive a list of Account records. The method must be static and the component uses the wire service to invoke it. Which annotation combination should the developer apply to the Apex method?

⚠ Common exam trap

The trap here is assuming @AuraEnabled alone supports the wire service, when cacheable=true is required for wired calls.

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

✓

@AuraEnabled(cacheable=true) on a static method that returns a List<Account>.

The wire service requires a static Apex method annotated with @AuraEnabled(cacheable=true) and a serializable return type such as List<Account>. Cacheable enables the wire adapter to cache results and refresh on reactive parameter changes. Instance methods and non-cacheable annotations do not satisfy the wire service contract.

Answer analysis

Option-by-option breakdown

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

  • ✓

    @AuraEnabled(cacheable=true) on a static method that returns a List<Account>.

    Why this is correct

    The wire service requires the Apex method to be annotated with @AuraEnabled(cacheable=true) and declared static. Returning a List<Account> is a supported serializable type. The cacheable attribute allows the wire adapter to cache results and refresh them reactively when reactive parameters change, which is exactly what the wire service expects.

  • ✗

    @AuraEnabled(cacheable=true) on a static method that returns a custom inner class instance.

    Why it's wrong here

    While custom Apex classes can be returned if they are serializable, the requirement here is a list of Account records. Returning a custom inner class would not provide the sObject data the component expects and would require additional mapping, making it the wrong choice for exposing Account records directly.

  • ✗

    @AuraEnabled on a static method with no cacheable attribute, returning a List<Account>.

    Why it's wrong here

    A method annotated only with @AuraEnabled can be called imperatively from JavaScript, but the wire service specifically requires cacheable=true. Without it, the wire adapter cannot cache or refresh the result, and the component will fail to receive wired data as intended.

  • ✗

    @AuraEnabled(cacheable=true) on an instance method that returns a List<Account>.

    Why it's wrong here

    Apex methods exposed to Lightning components must be static; instance methods cannot be invoked by the wire service or by imperative Apex calls. Even with the correct annotation and return type, an instance method will not be callable from the component, so this option fails on the method declaration itself.

About these practice questions

Courseiva writes every SF-PD2 question from scratch — 226 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or 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.