Plat-Dev-201 practice question 12 of 30
Which code statement includes an Apex method named updateAccounts in the class AccountController for use in a Lightning web component?
Full set: 204 questionsTo call an Apex method from a Lightning Web Component (LWC), the method must be imported into the component's JavaScript file. The correct syntax for this import statement is import methodName from '@salesforce/apex/ClassName.methodName'. This syntax tells the LWC framework to make the specified @AuraEnabled Apex method available for the component to call. The @salesforce/apex scoped module provides the mechanism to communicate with the Apex controller from the client-side JavaScript.
A. This syntax is incorrect. It lacks the required @salesforce/apex scoped module and the specific method name, and contains a typo in the class name.
B. This syntax is incorrect. It uses Salesforce/apex/ instead of the required @salesforce/apex scoped module and a colon instead of a period.
C. This syntax is incorrect. It is missing the @salesforce/apex scoped module which is necessary to identify the import as an Apex method.
- Salesforce Lightning Web Components Dev Guide, "Call Apex Methods", Section: "Import an Apex Method". The guide explicitly shows the syntax: import apexMethodName from '@salesforce/apex/Namespace.ClassName.apexMethodName';.
- Salesforce Apex Developer Guide, "Calling Apex from Lightning Web Components", Section: "Calling an Apex Method". This section reinforces the import syntax and the requirement for the Apex method to be static and @AuraEnabled.
Keep practicing
Take the free Plat-Dev-201 practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other Plat-Dev-201 practice questions
- Question 1Which three steps allow a custom Scalable Vector Graphic (SVG) to be included in a Lightn…
- Question 2Which two statements are true about using the @testSetup annotation in an Apex test class…
- Question 3Managers at Universal Containers want to ensure that only decommissioned containers are a…
- Question 4Universal Containers has a Visualforce page that displays a table of every Container__c b…
- Question 5A developer is alerted to an issue with a custom Apex trigger that is causing records to …
- Question 6Which two operations affect the number of times a trigger can fire? Choose 2 answers
