Salesforce Platform Developer I (legacy) — Question 176
Which two statements are acceptable for a developer to use inside procedural loops? (Choose two.)
Answer options
- A. delete contactList;
- B. contactList.remove(i);
- C. Contact con = new Contact();
- D. Account a = [SELECT Id, Name FROM Account WHERE Id = :con.AccountId LIMIT 1];
Correct answer: B, C
Explanation
Option B is correct because it involves removing an element from a list, which is action typically performed within a loop. Option C is also correct as it creates a new instance of the Contact class, which is permissible in a loop. Options A and D are incorrect because deleting a variable and executing a SOQL query are not appropriate actions for procedural loops.