次のコード スニペットの結果は何でしょうか? public word doWork(Account acct) { for (Integer i = 0; i <= 2007 i++) { insert acct; }
正解:D
ThedoWorkmethod inserts an account for every iteration of theforloop, which runs fromi = 0toi <= 200, inclusive. This results in 201 iterations, and hence 201 accounts are inserted into the org. Explanation of Code Behavior: The loop conditioni <= 200runs 201 times (0 to 200). Theinsert acct;statement is executed 201 times. Apex Developer Guide - Loop Constructs