I was going through your code snippet and I figured that option (A) is the best solution. Because when you use this code snippet with the help of first for loop you get all account id of all opportunity which is present in opportunityList and with the help of the second loop you get all the contact related to accountIds.
Option (B) is wrong because contactIds initialization is not done.
Option (C) the best practices of salesforce has not been followed.
Option (D) is wrong because of this list.AccountID is used and the list is not a type of Ids.
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards, Deepali Kulshrestha www.kdeepali.com
I was going through your code snippet and I figured that option (A) is the best solution.
Because when you use this code snippet with the help of first for loop you get all account id of all opportunity which is present in opportunityList and with the help of the second loop you get all the contact related to accountIds.
Option (B) is wrong because contactIds initialization is not done.
Option (C) the best practices of salesforce has not been followed.
Option (D) is wrong because of this list.AccountID is used and the list is not a type of Ids.
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Deepali Kulshrestha
www.kdeepali.com