When the number of records in a recordset is unknown, which control statement should a developer use to implement a set of code that executes for every record in the recordset, without performing a .size() or .length() method call? correct answers FOR (VARIABLE : LIST_OR_SET) { ... }
List or se...
When the number of records in a recordset is unknown, which control statement should
a developer use to implement a set of code that executes for every record in the
recordset, without performing a .size() or .length() method call? correct answers FOR
(VARIABLE : LIST_OR_SET) { ... }
List or set iteration for loops do not need the size of the collection to run.
What is the value of x after the code segment executes?
String x = 'A';
Integer i = 10;
if ( i < 15 ){
i = 15; x = 'B';
} else if ( i < 20 ){
x = 'C';
} else {
x = 'D';
} correct answers B
These if statements are evaluating the value of i. Since i is equal to 10 then i is less
than 15 and i will be reassigned the value 15 and x will be equal to 'B'. Once the values
are assigned the if statement is no longer run.
TRUE or FALSE: Say if below is an accurate statement about variable scope.
A VARIABLE CAN BE DEFINED AT ANY POINT IN A BLOCK. correct answers TRUE
A variable is valid from the point where it is declared inside of the code.
TRUE or FALSE: Say if below is an accurate statement about variable scope.
TRUE or FALSE: Say if below is an accurate statement about variable scope.
PARALLEL BLOCKS CAN USE THE SAME VARIABLE NAME. correct answers TRUE
TRUE or FALSE: Say if below is an accurate statement about variable scope.
SUB-BLOCKS CAN REUSE A PARENT BLOCK'S VARIABLE NAME IF ITS VALUE IS
NULL. correct answers FALSE
,TRUE or FALSE: Say if below is an accurate statement about variable scope.
A STATIC VARIABLE CAN RESTRICT THE SCOPE TO THE CURRENT BLOCK IF
ITS VALUE IS NULL. correct answers FALSE
Which two users can edit a record after it has been locked for approval? correct
answers An administrator and a user who is assigned as the current approver
What happens to changes in the result when a Visualforce page calls an Apex
controller, which calls another Apex class, and then hits a governor limit? correct
answers Any changes up to the error are rolled back
A developer in a Salesforce org with 100 accounts executes the following code using
the Developer Console.
Account myAccount = new Account(Name='MyAccount');
insert myAccount;
for (Integer x = 0; x < 150; x++){
Account newAccount = new Account(Name='MyAccount' + x);
try{
insert newAccount;
}catch (Exception ex){
System.Debug(ex);
}
}
insert new Account(Name='MyAccount');
How many accounts are in the org after this code is run? correct answers 100
Salesforce has a governor limit of 150 DML statements per transaction. The Salesforce
org originally starts with 100 accounts. The first DML statement inserts the first account
leaving 149 DML statements available. Inside the for loop it tries to make 150 DML
statements. But the limit is reached when x = 149. When this happens the transaction
aborts and all data changes are rolled back. The only thing that is left is the original 100
accounts. Since the error happened the last insert statement is never reached. Best
practice is to avoid DML statements inside for loops.
TRUE or FALSE: Should developers avoid using the statement below inside procedural
loops?
LIST CONTACTS = [SELECT ID, SALUTATION, FIRSTNAME, LASTNAME, EMAIL
FROM CONTACT WHERE ACCOUNTID = :A.ID]; correct answers TRUE
Avoid using SOQL in loops since there is a governor limit that enforces a maximum
number of SOQL queries. When these operations are placed inside a loop, database
operations are invoked once per iteration of the loop making it very easy to reach these
, governor limits. Best practice is to query once to obtain all results, and then iterate over
the results.
TRUE or FALSE: Should developers avoid using the statement below inside procedural
loops?
UPDATE CONTACTLIST; correct answers TRUE
Avoid using DML in loops since there is a governor limit that enforces a maximum
number of DML statements. When these operations are placed inside a loop, database
operations are invoked once per iteration of the loop making it very easy to reach these
governor limits.
TRUE or FALSE: Should developers avoid using the statement below inside procedural
loops?
SYSTEM.DEBUG('AMOUNT OF CPU TIME (IN MS) USED SO FAR: ' +
LIMITS.GETCPUTIME()); correct answers FALSE
System.debug is a great way to test the output especially in loops.
TRUE or FALSE: Should developers avoid using the statement below inside procedural
loops?
IF (O.ACCOUNTID == A.ID) correct answers FALSE
An if statement can be used inside of a loop to create a condition.
Which data structure is returned to a developer when performing a SOSL search?
correct answers A list of lists of sObjects
A developer runs the following anonymous code block.
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller HopeJewels. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $12.99. You're not tied to anything after your purchase.