nerdexam
Salesforce

PDI · Question #220

Which annotation should a developer use on an Apex method to make it available to be wired to a property in a Lightning web component?

The correct answer is C. @AureEnabled (cacheable=true). To enable an Apex method for wiring in a Lightning Web Component, it must be annotated with @AuraEnabled and specifically (cacheable=true) if the data is read-only and can be cached client-side.

Submitted by minji_kr· Apr 18, 2026User Interface

Question

Which annotation should a developer use on an Apex method to make it available to be wired to a property in a Lightning web component?

Options

  • A@RemoteAction
  • B@AureEnabled
  • C@AureEnabled (cacheable=true)
  • D@RemoteAction(|cacheable=true)

How the community answered

(34 responses)
  • A
    6% (2)
  • B
    3% (1)
  • C
    88% (30)
  • D
    3% (1)

Why each option

To enable an Apex method for wiring in a Lightning Web Component, it must be annotated with `@AuraEnabled` and specifically `(cacheable=true)` if the data is read-only and can be cached client-side.

A@RemoteAction

`@RemoteAction` is used for exposing Apex methods to Visualforce pages for JavaScript remoting, not for wiring to properties in Lightning Web Components.

B@AureEnabled

`@AuraEnabled` without `(cacheable=true)` exposes the method but does not enable client-side caching, which is a key performance feature for wired properties that retrieve read-only data.

C@AureEnabled (cacheable=true)Correct

The `@AuraEnabled(cacheable=true)` annotation exposes an Apex method to Lightning Web Components for data retrieval, allowing the LWC framework to cache the method's results on the client-side for performance optimization when the data is read-only and doesn't require modifications.

D@RemoteAction(|cacheable=true)

The syntax `@RemoteAction(|cacheable=true)` is incorrect; `cacheable=true` is an attribute of `@AuraEnabled`, and `@RemoteAction` is for Visualforce remoting, not LWCs.

Concept tested: Apex method annotations for Lightning Web Components (LWC) wiring

Source: https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/apex_api_methods.htm

Topics

#Lightning Web Components#Apex Annotations#@wire service#AuraEnabled

Community Discussion

No community discussion yet for this question.

Full PDI Practice