Salesforce Certified Platform Developer II — Question 224

global with sharing class MyRemoter {
public String accountName { get; set; }
public static Account account { get; set; }
public AccountRemoter() {}
@RemoteAction
global static Account getAccount(String accountName) {
account = [SELECT Id, Name, NumberOfEmployees
FROM Account WHERE Name = :accountName];
return account;
}
}
Consider the Apex class above that defines a RemoteAction used on a Visualforce search page.
Which code snippet will assert that the remote action returned the correct Account?

Answer options

Correct answer: D

Explanation

The correct answer is D because it directly calls the static method getAccount on the MyRemoter class, which is designed to fetch the Account based on the provided name. The other options either instantiate the class unnecessarily or do not call the method correctly, thus failing to validate the retrieval of the correct Account.