Go Back on PDII Exam
Available in 1, 3, 6 and 12 Months Free Updates Plans
PDF: $15 $60

Test Engine: $20 $80

PDF + Engine: $25 $99

PDII Practice Test


Page 6 out of 39 Pages

How should a developer assert that a trigger with an asynchronous process has successfully run?


A. Create at test data in the test class, use System.runAs() to invoke the trigger, then perform assertions.


B. Insert records into Salesforce, use seeAllData-true, then perform assertions.


C. Create all test data, use @future In the test class, then perform assertions.


D. Create all test data in the test class, invoke Test.startTest() and Test.stopTest() and then perform assertions.





D.
  Create all test data in the test class, invoke Test.startTest() and Test.stopTest() and then perform assertions.




Explanation:

Test.startTest() and Test.stopTest() are used to ensure that any asynchronous processes (like @future methods, batch Apex, or queueable jobs) have been executed and completed within a test method. These methods simulate a fresh execution context and allow the developer to assert that the asynchronous process was executed successfully.

Universal Containers has an Apex trigger on Account that creates an Account Plan record when an Account is marked as a Customer. Recently a record-triggered flow was added so that whenever an Account is marked as a Customer, a ‘Customer Since’ date field is updated with today’s date. Since the addition of the flow, two Account Plan records are created whenever the Account is marked as a Customer. What might cause this to happen?


A. The flow is configured to evaluate when a record is created and every time it is edited.


B. The Apex trigger is not bulk safe and calls insert inside of a for loop.


C. The Apex trigger does not use a static variable to ensure it only fires once.


D. The flow is configured to use an ‘Update Records’ element.





C.
  The Apex trigger does not use a static variable to ensure it only fires once.




Explanation:

In Salesforce, both a trigger and a flow could be updating the same record, causing the trigger to run multiple times. If the Apex trigger doesn't use a static variable to prevent multiple executions in a single transaction, it can result in creating duplicate records. The static variable ensures that the trigger only fires once, even if the record is updated multiple times within the same transaction.

There are user complaints about slow render times of a custom data table within a Visualforce page that loads thousands of Account records at once. What can a developer do to help alleviate such issues?


A. Use the transient keyword in the Apex code when querying the Account records


B. Use JavaScript remoting to query the accounts


C. Use the standard Account List controller and implement pagination


D. Upload a third-party data table library as a static resource





C.
  Use the standard Account List controller and implement pagination

A developer is building a Lightning web component that searches for Contacts and must communicate the search results to other Lightning web components when the search completes. What should the developer do to implement the communication?


A. Publish an event on an event channel.


B. Fire an application event.


C. Publish a message on a message channel.


D. Fire a custom component event.





C.
  Publish a message on a message channel.

A developer is debugging an Apex-based order creation process that has a requirement to have three savepoints, SP1, SP2, and 5P3 {created in order), before the final execution of the process. During the final execution process, the developer has a routine to roll back to SP1 for a given condition. Once the condition is fixed, the code then calls 2 roll back to SP3 to continue with final execution. However, when the roll back to SP3 is called, a Funtime error occurs. Why does the developer receive a runtime error?


A. SP3 became invalid when SP1 was rolled back.


B. The developer has too many DML statements between the savepoints.


C. The developer used too many savepoints in one trigger session.


D. The developer should have called SF2 before calling SP3.





A.
  SP3 became invalid when SP1 was rolled back.


Page 6 out of 39 Pages
Previous