Salesforce Certified Platform Developer II Exam Practice Questions (P. 5)
- Full Access (424 questions)
- Six months of Premium Access
- Access to one million comments
- Seamless ChatGPT Integration
- Ability to download PDF files
- Anki Flashcard files for revision
- No Captcha & No AdSense
- Advanced Exam Configuration
Question #41
Which statement should be used to allow some of the records in a list of records to be inserted if others fail to be inserted?
- Ainsert (records, false)
- BDatabase.insert(records, false)
- CDatabase.insert(records, true)
- Dinsert records
Correct Answer:
B
B
send
light_mode
delete
Question #42
Which two relationship queries use the proper syntax? (Choose two.)
- ASELECT Id, Name, Account__r.Name FROM Contact WHERE Account__r.Industry = 'Media'
- BSELECT Name, (SELECT LastName FROM Contacts__r) FROM Account
- CSELECT Name, (SELECT LastName FROM Contacts) FROM Account
- DSELECT Id, Name, Account.Name FROM Contact WHERE Account.Industry = 'Media'
Correct Answer:
CD
CD
send
light_mode
delete
Question #43
A developer built a Component to be used at the front desk for quests to self-register upon arrival at a kiosk. The developer is now asked to create a Component for the Utility Tray to alert Users whenever a guest has arrived at the front desk.
What should be used?
What should be used?
- AApplication Event
- BDML Operation
- CComponent EventMost Voted
- DChangeLog
Correct Answer:
A
A
send
light_mode
delete
Question #44
Given a list of Opportunity records named opportunityList, which code snippet is best for querying all Contacts of the Opportunity's Account?
- AList <Contact> contactList = new List <Contact>(); for(Opportunity o : opportunityList){ Account a = [SELECT Id, (SELECT Id FROM Contacts) FROM Account WHERE Id = :o.AccountId] contactList.addAll(a.Contacts); )
- BList <Contact> contactList = new List <Contact>(); Set <Id> accountIds = new Set <Id> (); for (Opportunity o : opportunityList){ contactIds.add(o.ContactId); } for(Contact c : [SELECT Id FROM Contact WHERE Id IN :contactIds]){ contactList.add(c); }
- CList <Contact> contactList = new List <Contact>(); Set <Id> accountIds = new Set <Id> (); for(Opportunity o : opportunityList){ accountIds.add(o.AccountId); } for(Account a : [SELECT Id, (SELECT Id FROM Contacts) FROM Account WHERE Id IN :accountIds]){ contactList.addAll(a.Contacts); }Most Voted
- DList <Contact> contactList = new List <Contact>(); for ( Contact c : [SELECT Id FROM Contact WHERE AccountId IN :opportunityList.AccountId] ){ contactList.add(c); }
Correct Answer:
C
C
send
light_mode
delete
Question #45
An Apex Trigger creates a Contract record every time an Opportunity record is marked as Closed and Won. This trigger is working great, except (due to a recent acquisition) historical Opportunity records need to be loaded into the Salesforce instance.
When a test batch of records is loaded, the Apex Trigger creates Contract records. A developer is tasked with preventing Contract records from being created when mass loading the Opportunities, but the daily users still need to have the Contract records created.
What is the most extendable way to update the Apex Trigger to accomplish this?
When a test batch of records is loaded, the Apex Trigger creates Contract records. A developer is tasked with preventing Contract records from being created when mass loading the Opportunities, but the daily users still need to have the Contract records created.
What is the most extendable way to update the Apex Trigger to accomplish this?
- AUse a Hierarchy Custom Setting to disable the Trigger for the user who does the data loading.
- BUse a List Custom Setting to disable the Trigger for the user who does the data loading.
- CAdd the Profile Id of the user who does the data loading to the Trigger so the Trigger won't fire for this user.
- DAdd a Validation Rule to the Contract to prevent Contract creation by the user who does the data loading.
Correct Answer:
A
A
send
light_mode
delete
Question #46
Business rules require a Contact to always be created when a new Account is created.
What can be used when developing a custom screen to ensure an Account is not created if the creation of the Contact fails?
What can be used when developing a custom screen to ensure an Account is not created if the creation of the Contact fails?
- AUse the Database.Delete method if the Contact insertion fails.
- BUse the Database.Insert method with allOrNone set to False.
- CDisable Validation rules on Contacts and set default values with a Trigger.
- DUse setSavePoint() and rollback() with a try/catch block.
Correct Answer:
D
D
send
light_mode
delete
Question #47
trigger AssignOwnerByRegion on Account ( before insert, before update )
{
List<Account> accountList = new List<Account>();
for( Account anAccount : trigger.new )
{
Region__c theRegion = [
SELECT Id, Name, Region_Manager__c
FROM Region__c -
WHERE Name = :anAccount.Region_Name__c
];
anAccount.OwnerId = theRegion.Region_Manager__c;
accountList.add( anAccount );
}
update accountList;
}
Consider the above trigger intended to assign the Account to the manager of the Account's region.
Which two changes should a developer make in this trigger to adhere to best practices? (Choose two.)
{
List<Account> accountList = new List<Account>();
for( Account anAccount : trigger.new )
{
Region__c theRegion = [
SELECT Id, Name, Region_Manager__c
FROM Region__c -
WHERE Name = :anAccount.Region_Name__c
];
anAccount.OwnerId = theRegion.Region_Manager__c;
accountList.add( anAccount );
}
update accountList;
}
Consider the above trigger intended to assign the Account to the manager of the Account's region.
Which two changes should a developer make in this trigger to adhere to best practices? (Choose two.)
- AUse a Map to cache the results of the Region__c query by Id.
- BMove the Region__c query to outside the loop.Most Voted
- CRemove the last line updating accountList as it is not needed.Most Voted
- DUse a Map accountMap instead of List accountList.
Correct Answer:
AD
AD
send
light_mode
delete
Question #48
Example 1:
AggregateResult[] groupedResults = [SELECT CampaignId, AVG(Amount) FROM Opportunity GROUP BY CampaignId]; for (AggregateResult ar : groupedResults)
{
System.debug('Campaign ID' + ar.get('CampaignId'));
System.debug('Average amount' + ar.get('expr0'));
}
Example 2:
AggregateResult[] groupedResults = [SELECT CampaignId, AVG(Amount) theAverage FROM Opportunity GROUP BY CampaignId]; for (AggregateResult ar : groupedResults)
{
System.debug('Campaign ID' + ar.get('CampaignId'));
System.debug('Average amount' + ar.get('theAverage'));
}
Example 3:
AggregateResult[] groupedResults = [SELECT CampaignId, AVG(Amount) FROM Opportunity GROUP BY CampaignId]; for (AggregateResult ar : groupedResults)
{
System.debug('Campaign ID' + ar.get('CampaignId'));
System.debug('Average amount' + ar.get.AVG());
}
Example 4:
AggregateResult[] groupedResults = [SELECT CampaignId, AVG(Amount) theAverage FROM Opportunity GROUP BY CampaignId]; for (AggregateResult ar : groupedResults)
{
System.debug('Campaign ID' + ar.get('CampaignId'));
System.debug ('Average amount' + ar.theAverage);
}
Which two of the examples above have correct System.debug statements? (Choose two.)
AggregateResult[] groupedResults = [SELECT CampaignId, AVG(Amount) FROM Opportunity GROUP BY CampaignId]; for (AggregateResult ar : groupedResults)
{
System.debug('Campaign ID' + ar.get('CampaignId'));
System.debug('Average amount' + ar.get('expr0'));
}
Example 2:
AggregateResult[] groupedResults = [SELECT CampaignId, AVG(Amount) theAverage FROM Opportunity GROUP BY CampaignId]; for (AggregateResult ar : groupedResults)
{
System.debug('Campaign ID' + ar.get('CampaignId'));
System.debug('Average amount' + ar.get('theAverage'));
}
Example 3:
AggregateResult[] groupedResults = [SELECT CampaignId, AVG(Amount) FROM Opportunity GROUP BY CampaignId]; for (AggregateResult ar : groupedResults)
{
System.debug('Campaign ID' + ar.get('CampaignId'));
System.debug('Average amount' + ar.get.AVG());
}
Example 4:
AggregateResult[] groupedResults = [SELECT CampaignId, AVG(Amount) theAverage FROM Opportunity GROUP BY CampaignId]; for (AggregateResult ar : groupedResults)
{
System.debug('Campaign ID' + ar.get('CampaignId'));
System.debug ('Average amount' + ar.theAverage);
}
Which two of the examples above have correct System.debug statements? (Choose two.)
send
light_mode
delete
Question #49
Which method should be used to convert a Date to a String in the current user's locale?
send
light_mode
delete
Question #50
A company has a custom object, Order__c, that has a required, unique, external ID field called Order_Number__c.
Which statement should be used to perform the DML necessary to insert new records and update existing records in a List of Order__c records?
Which statement should be used to perform the DML necessary to insert new records and update existing records in a List of Order__c records?
- Aupsert orders;
- Bupsert orders Order_Number__c;Most Voted
- Cmerge orders Order_Number__c;
- Dmerge orders;
Correct Answer:
B
B
send
light_mode
delete
All Pages