Process Automation & Logic: Basic Apex 2 Flashcards
Conditionals | Loops | Switch | Apex Control Flow (31 cards)
What are the different conditional statements?
IF, IF-ELSE, ELSE-IF
What are the different looping constructs?
Traditional For loop
List/Set For loop
SOQL For Loop
While Loop
Do-While Loop
Repeated _________ statements can be used, and each condition will be evaluated sequentially until one of the expressions evaluates to true.
else if
Using else if statements allow using as many code blocks as needed. True or False?
True
A _____________ executes a block of code repeatedly based on initialization, exit condition, and increment.
traditional for loop
A traditional for loop uses the following syntax:
for (initialization; condition; increment) { code_block }
The List or Set iteration loop uses the following syntax:
for (type variable: listOrSet)
{
code_block
}
The variable data type should be of the same data type contained in the list or set collection. True or False?
True
Are you allowed to add or remove items from a collection while iterating through the collection?
No, this is not allowed and will throw an exception.
An __________ processes the results of an SOQL query that is defined in the loop.
SOQL for loop
Query results are processed in batches of ___ records or one record at a time depending on the variable data type used
200
The _______ is used to execute a code block repeatedly as long as a particular condition is true.
while loop
The ________ can be used when the loop needs to be executed at least once.
do-while loop
____________ can be defined to create a custom set of instructions when traversing a List collection.
Custom iterators
What are some considerations for using custom iterators?
The methods in the custom iterator must be defined as global or public. Custom iterators can be used in while loops only. To use custom iterators in for loops, the Iterable interface can be used.
Custom iterators can be used to process data that come from __________, or it can also be used to traverse complex data such as queries with multiple SELECT statements.
outside Salesforce
To create a custom iterator, the Iterator interface is implemented that uses _________ for determining if there is still an item in the collection to traverse and _______ for retrieving the next item.
hasNext(), next()
The _______ statement can be used conditionally within a procedural loop statement to exit the entire loop.
break
The _________ statement can be used conditionally within a procedural loop statement to skip the current iteration and jump to the next iteration.
continue
A ________ can be used to determine if an expression matches one of several values and branches.
switch statement
The keyword _____ is used to match values. The _______ value can be a single value, multiple values, or sObject types.
when
If there is no matching value, the when else code block is executed, which must be the last block in the switch statement. If there is no when else block, no action is taken. True or False?
True
It is possible to nest Apex switch statements to provide multiple execution paths within a when clause. True or False?
True
Each when value must be unique, and it is possible for a value to be null. True or False?
True