Salesforce Certified Platform Developer II (Plat-Dev-301) Exam Practice Test

Page: 1 / 14
Total 202 questions
Question 1

Universal Containers wants to notify an external system, in the event that an unhandled exception occurs, by publishing a custom event using Apex.

What is the appropriate publish/subscribe logic to meet this requirement?



Answer : A

When an unhandled exception occurs, publishing a custom platform event using EventBus.publish() method is the appropriate way. The external system can then subscribe to this event using technologies like CometD to receive notifications. Reference: Publish and Subscribe to Platform Events


Question 2

A developer wrote the following method to find all the test accounts in the org:

What should be used to fix this failing test?



Answer : A

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_testing_SOSL.htm


Question 3

A developer has a Visualforce page that automatically assigns ewnership of an Account to a queue upon save. The page appears to correctly assign ownership, but an assertion validating the correct ownership fails.

What can cause this problem?



Answer : A

If the test class does not retrieve the updated value from the database, it will not see any changes made by the page logic. This can cause assertions that check for those changes to fail. The test should query for the most recent value from the database after the operation that is supposed to update the value.


Question 4

A developer is writing a Visualforce page that queries accounts in the system and presents a data table with the results. The users want to be able to filter the results based on up to five fields. However, the users want to pick the five fields to use as filter fields when they run the page.

Which Apex code feature is required to facilitate this solution?



Answer : D

The requirement described in the question calls for a flexible way to query records based on user-selected fields. Dynamic SOQL is the perfect tool for this job as it allows the construction of a SOQL string at runtime, which can include any number of fields and filter conditions that are determined at the time the user interacts with the page. This enables the creation of a highly customizable query interface. A, B, and C are not suitable for this requirement as they serve different purposes: A (Streaming API) is for receiving real-time streams of data changes, B (Metadata API) is for managing the metadata of your Salesforce org, and C (variable binding) is used in Visualforce to bind data between the page and the controller but does not provide dynamic query capabilities.

Reference

Dynamic SOQL: Dynamic SOQL in Apex Developer Guide


Question 5

An Apex trigger and Apex class increment a counter, Edit __C, any time the Case is changed.

A)

B)

C)

D)



Answer : C


Question 6

Universal Containers stores user preferences in a Hierarchy Custom Setting, User_Prefs_c, with a Checkbox field, Show_Help_c. Company-level defaults are stored at the organizational level, but may be overridden at the user level. If a user has not overridden preferences, then the defaults should be used.

How should the Show_Help_c preference be retrieved for the current user?



Answer : B

To retrieve the Show_Help__c preference for the current user from a hierarchy custom setting, the getInstance() method should be used. This method retrieves the custom setting data for the user or the organization default if no user-specific setting is found.


Question 7

A developer is developing a reusable Aura component that will reside on an sObject Lightning page with the following HTML snippet:

How can the component"5 controller get the context of the Lightning page that the sObject is on without requiring additional test coverage?



Answer : A

By implementing force:hasSobjectName, the Aura component can retrieve the sObject context of the record page it is placed on without needing additional information. This interface provides the component with the API name of the sObject being displayed.


Aura Components Developer Guide

Page:    1 / 14   
Total 202 questions