Certified Platform Developer II Exam QuestionsBrowse all questions from this exam

Certified Platform Developer II Exam - Question 15


A developer is asked to update data in an org based on new business rules. The new rules state that Accounts with the type set to 'Customer' should have a status of 'Active', and Accounts with the type set to 'Prospect' should have a status of 'Pending'. No other changes to data should be made.

Which code block will accurately meet the business requirements?

Show Answer
Correct Answer: C

The correct code block must update the status of Accounts based on their type being either 'Customer' or 'Prospect', while making no other changes to the data. Option C accomplishes this accurately by iterating over all accounts, checking if the type is 'Customer' or 'Prospect', and then setting the status to 'Active' or 'Pending' respectively. It correctly handles null or empty type values by explicitly checking that the type is not blank before updating the status, thus avoiding unintended changes.

Discussion

17 comments
Sign in to comment
kushalbakshiOption: C
Jan 12, 2021

This should be 'C'. D option will update all the Account records instead of only the required ones.

KAALISHANOption: B
May 6, 2023

B seems to be the right answer. It has the status in the query, and does the update as required. Not sure why no one is considering B and not saying why it's wrong either!

Sri0507
Dec 14, 2023

B is not correct because in the query, filter is Status and it should be Type not Status. So it will never enter into for loop.

agjklsjrhgjksfOption: A
May 19, 2022

Only A does it all. C doesn't do second half of the task.

suddebOption: C
Mar 11, 2022

Answer D cannot be right. This solution will fail at the 3rd line, because you would set the ‘Pending’ status for every other type than customer. Also e.g. for ‘Agency’. This means for type ‘Customer’ you would set the status ‘Active’ correctly, but for EVERY other type (Prospect, but ALSO other types) you would set the status to ‘Pending’. Answer B can’t be right as well, because the WHERE clause is filtering for “Status” IN the map’s keySet, means it checks for a status with values “Customer” or “Prospect” (which are the Account’s Type values). Therefore it will not return any account records to iterate over. C looks to me the correct answer

pushpapa_1980Option: A
Jan 12, 2021

A seems to be the best answer. C will be evaluated against both Customer and prospect since it is missing If Else statement. B is definitely not the answer. D is also not the answer since it updates all the records.

NPW89Option: C
Nov 10, 2021

A can be correct if where condition as follows. SELECT Id, Type FROM Account WHERE Type IN :statusMap.keySet() answer is C

amilaveerOption: B
Dec 17, 2022

All the answers are incorrect because "Status " is not in SOQL. Other than that "B" is the correct answer

CraigJOption: A
May 8, 2021

While C is not ideal in it misses the else statement A assumes that there are only two options for the customer type. Crappy question.

skipper009
Jan 19, 2022

Does anyone notice that status wasn't included in any of the SELECT? Update on any of the choices should not work.

JasonZhaoOption: A
Jan 21, 2022

This should be A. Option C will increase the APEX CPU Time more than A.

parishkOption: B
Feb 1, 2022

Its option B as the Account SOQL query filter only the required fields

karappoOption: C
Feb 14, 2023

Should be C. A will also update account with type = null or empty

code_breaker_27
Sep 19, 2023

Since the questoin mentioned "No other changes to data should be made", ALL answers are wrong. Query should filter Account Type IN ('Customer', 'Prospect') or should filter result if Type == Customer or Type == Prospect and only add them to the list to be updated.

Nikas008Option: C
Oct 24, 2023

Write answer is C, A and D can changing Accounts with other Types and B will give you not correct data because of wrong SOQL

FriedConsole2000Option: B
Feb 8, 2024

It is B

c2ff438Option: C
Apr 4, 2024

Should be C

corpexOption: A
May 15, 2024

A. Is correct and more optimized. With .containsKey null values are avoided. B. Is wrong because the soql is filtering by Status instead of Type, It wont receive any result C. Is correct but it less maintenable and less flexible. Mapping is a better choice. D. Is wrong because it will update all accounts with null types to Pending. In my opinion the option B was badly written in examtopics and the original exam had the soql filtering by Type which would make it perfect in terms of optimization, but in this context, A should be the correct anwser.