function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Puja Gupta 18Puja Gupta 18 

Need help for find correct answer

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?


Extend each class from the same base class that has a method getTextSummary() that returns the summary.
Have each class define method getTextSummary() that returns the summary.
Have each class define method getObject() that returns the sObject that is controlled by the Apex class.
Have each class implement an interface that defines method getTextSummary() that returns the summary.

 

Please let me know which is correct answer form above.

S95S95
hi Puja,
Have each class implement an interface that defines method getTextSummary() that returns the summary.

thanks,
sruthi
SarthakSarthak

@sruthi S95, None of the methods are implemeted in interfaces , if we choose this option we need to implement getTextSummary() method for all the class which uses the interface. I think first option i.e. extend each class from same base class is the correct answer. Please let me know if my understanding is wrong,

Thanks,

Sarthak

Parikhit SarkarParikhit Sarkar
Looks like this can also be an answer:
Extend each class from the same base class that has a method getTextSummary() that returns the summary.

Regards,

Parikhit .
Debaranjan GhoshDebaranjan Ghosh
Interface should be the correct answer as in Practical world mutiple Apex Classes highly wont have same parent and in order to use the same function for all of them Interface is the only possible solution
Regards 
Debaranjan