Salesforce Platform Developer I (legacy) — Question 279

A developer created a Lightning component to display a short text summary for an object and wants to use it with multiple Apex classes.
How should the developer design the Apex classes?

Answer options

Correct answer: C

Explanation

The correct answer is C because implementing an interface allows different classes to provide their own specific implementations of getTextSummary(), ensuring flexibility and adherence to a contract. Option A is incorrect as it does not standardize the summary method. Option B limits the design to a single base class, which may not be ideal for all use cases. Option D lacks the benefits of polymorphism provided by interfaces.