What are the five types of Apex procedural loops?
Click on the arrows to vote for the correct answer
A. B. C. D.A.
The correct answer is A. Do-while loop, traditional for loop, list or set iteration loops, and soql for loops.
Here's a detailed explanation of each loop:
javascriptdo { // code block } while (condition);
scssfor (initialization; condition; increment) { // code block }
javascriptList<Object> myList = new List<Object>{1, 2, 3}; for (Object obj : myList) { // code block }
The syntax for a set iteration loop in Apex is similar, except that it iterates over a set:
javascriptSet<Object> mySet = new Set<Object>{1, 2, 3}; for (Object obj : mySet) { // code block }
cssfor (sObject s : [SELECT ... FROM ...]) { // code block }
javascriptwhile (condition) { // code block }
Overall, these five types of procedural loops in Apex provide developers with different options for iterating over collections of data or executing code while a certain condition is true.