Which code block will accurately meet the business requirements?

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?
A . Map<String, String> statusMap = new Map<String, String>{‘Customer’=>’Active’,
‘Prospect’=>’Pending’}
List<Account> accountUpdates = new List<Account>();
for ( Account a : [SELECT Id, Type FROM Account]){
if ( statusMap.containsKey(a.Type) ) {
a.Status = a.Type == ‘Customer’ ? ‘Active’ : ‘Pending’;
}
accountUpdates.add(a);
}
update accountUpdates;
B . Map<String, String> statusMap = new Map<String, String>{‘Customer’=>’Active’,
‘Prospect’=>’Pending’}
List<Account> accountUpdates = new List<Account>();
for ( Account a : [SELECT Id, Type FROM Account WHERE Status IN
:statusMap.keySet()]){
a.Status = statusMap.get(a.Type);
accountUpdates.add(a);
07B13F58239056B81577933EB624485B
}
update accountUpdates;
C . List<Account> accountUpdates = new List<Account>();
for ( Account a : [SELECT Id, Type FROM Account]){
if ( String.isNotBlank(a.Type) && a.Type == ‘Customer’ ){
a.Status = ‘Active’;
}
if ( String.isNotBlank(a.Type) && a.Type == ‘Prospect’ ){
a.Status = ‘Pending’;
}
accountUpdates.add(a);
}
update accountUpdades;

D . List<Account> accountUpdates = new List<Account>();
for ( Account a : [SELECT Id, Type FROM Account]){
a.Status = a.Type == ‘Customer’ ? ‘Active’ : ‘Pending’;
accountUpdates.add(a);
}
update accountUpdates;

Answer: C

Latest PDII Dumps Valid Version with 280 Q&As

Latest And Valid Q&A | Instant Download | Once Fail, Full Refund

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments