Salesforce Platform Developer I (legacy) — Question 240
A developer needs an Apex method that can process Account or Contact records.
Which method signature should the developer use?
Answer options
- A. public void doWork(Account | | Contact)
- B. public void doWork(Record theRecord)
- C. public void doWork(Account Contact)
- D. public void doWork(sObject theRecord)
Correct answer: D
Explanation
The correct answer is D because sObject is the base class for all Salesforce objects, allowing the method to accept any type of record, including Account and Contact. The other options either use incorrect syntax or limit the method to specific types, which would not fulfill the requirement to process both Account and Contact records.