Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.
exam questions

Exam CRT-450 All Questions

View all questions & answers for the CRT-450 exam

Exam CRT-450 topic 1 question 80 discussion

Actual exam question from Salesforce's CRT-450
Question #: 80
Topic #: 1
[All CRT-450 Questions]

Which two statements are acceptable for a developer to use inside procedural loops? (Choose two.)

  • 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];
Show Suggested Answer Hide Answer
Suggested Answer: BC 🗳️

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
BeatrizBernardo
Highly Voted 1 year, 5 months ago
Selected Answer: BC
better explain why not D is a right answer, can it the governor limits https://trailhead.salesforce.com/trailblazer-community/feed/0D54S00000A8GHjSAN
upvoted 5 times
...
ABHI0O07
Most Recent 8 months ago
do not ever use dml statements or querying records inside loops.so b and c are correct
upvoted 1 times
...
edogaldo
1 year, 2 months ago
also this might be interesting: https://salesforce.stackexchange.com/questions/76912/can-i-remove-element-from-a-list-being-looped-through
upvoted 1 times
...
de2rick
1 year, 6 months ago
Selected Answer: CD
B is not correct, normally there will be a compile error ERROR: Cannot modify a collection while it is being iterated. (FOR i loop could compile but out of index error eventually) D is correct even though the SOQL query in a loop is not the best practice but it can be complied properly
upvoted 1 times
sfarchex137
1 year, 2 months ago
Regardless of limit, the loop exceeds governor limits if it executes a large number of times. BC is the right answer
upvoted 2 times
...
edogaldo
1 year, 2 months ago
"D is correct even though the SOQL query in a loop is not the best practice but it can be complied properly": it would be the same also for A then...
upvoted 2 times
...
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...