Salesforce - Big Savings Alert – Don’t Miss This Deal - Ends In 1d 00h 00m 00s Coupon code: 26Y30OFF
  1. Home
  2. Salesforce
  3. Plat-Dev-301 Exam
  4. Free Plat-Dev-301 Questions

Free Practice Questions for Salesforce Plat-Dev-301 Exam

Pass4Future also provide interactive practice exam software for preparing Salesforce Certified Platform Developer II (Plat-Dev-301) Exam effectively. You are welcome to explore sample free Salesforce Plat-Dev-301 Exam questions below and also try Salesforce Plat-Dev-301 Exam practice test software.

Page:    1 / 14   
Total 161 questions

Question 1

Consider the Apex class below that defines a RemoteAction used on a Visualforce search page.

Java

global with sharing class MyRemoter {

public String accountName { get; set; }

public static Account account { get; set; }

public MyRemoter() {}

@RemoteAction

global static Account getAccount(String accountName) {

account = [SELECT Id, Name, NumberOfEmployees FROM Account WHERE Name = :accountName];

return account;

}

}

Which code snippet will assert that the remote action returned the correct Account?

A.

Java

MyRemoter remote = new MyRemoter();

Account a = remote.getAccount('TestAccount');

System.assertEquals( 'TestAccount', a.Name );

B.

Java

MyRemoter remote = new MyRemoter('TestAccount');

Account a = remote.getAccount();

System.assertEquals( 'TestAccount' , a.Name );

C.

Java

Account a = controller.getAccount('TestAccount');

System.assertEquals( 'TestAccount', a.Name );

D.

Java

Account a = MyRemoter.getAccount('TestAccount');

System.assertEquals( 'TestAccount', a.Name );



Answer : D

In Salesforce Apex, a @RemoteAction method must be defined as static. Static methods belong to the class itself rather than to a specific instance of the class. Therefore, when writing a unit test to verify the behavior of a RemoteAction, the method should be called using the class name notation (ClassName.methodName) rather than by instantiating the class first.

Option D correctly demonstrates the standard way to invoke a static method in Apex: Account a = MyRemoter.getAccount('TestAccount');. Because the method is static, it does not require the new keyword or a constructor to be called. Option A is incorrect because it attempts to call a static method on an instance variable (remote.getAccount), which is considered an illegal or improper reference in Apex. Option B is incorrect because it treats the RemoteAction like an instance method and assumes a non-existent constructor that takes a String. Option C is incorrect because it uses an undefined variable controller.

By calling the method statically in the test, the developer correctly simulates how the Visualforce Remoting engine calls the method from JavaScript at runtime. The assertion System.assertEquals then verifies that the record retrieved from the database matches the expected name, ensuring the search logic is functioning correctly.


Question 2

A developer created a Lightning web component that uses a lightning-record-edit-form to collect information about Leads. Users complain that they only see one error message at a time about their input when trying to save a Lead record. Which best practice should the developer use to perform the validations on more than one field, thus allowing more than one error message to be displayed simultaneously?



Answer : B

When using lightning-record-edit-form, server-side validation rules (Option D) typically return errors one at a time as the database engine encounters them, or as a single combined toast message that can be difficult to parse. To provide a superi1or user experience where multiple fields are validated simultaneously before the data even reaches the server, the develo2per shou3ld implement Client-side validation (Option B).

In the component's JavaScript controller, the developer can intercept the onsubmit event. By iterating through all the lightning-input-field or standard lightning-input elements, the developer can programmatically check for various conditions (e.g., custom regex patterns, conditional logic between fields, or range checks). Each field can then be marked with a custom error message using the reportValidity() or setCustomValidity() methods. This allows the UI to highlight all invalid fields at once, providing immediate, comprehensive feedback to the user. This approach reduces unnecessary server round-trips and ensures that the user can correct all issues in a single pass before successfully submitting the record.


Question 3

Consider the following code snippet:

HTML

Users of this Visualforce page complain that the page does a full refresh every time the Search button is pressed. What should the developer do to ensure that a partial refresh is made so that only t13he section identified with opportunityList is re-drawn on the screen?1415



Answer : D

In Visualforce, the standard behavior for an is to perform a full page postback. To convert this into an asynchronous (AJAX) request that only updates a specific portion of the page, the developer must use the reRender attribute (D). By setting reRender='opportunityList' on the command button, the developer instructs the platform to capture the server's response and update only the DOM element with that specific ID, rather than refreshing the entire browser window.

While Option C (returning null from the search method) is a requirement for staying on the same page, it does not prevent the full refresh by itself. Option A () is used to limit which part of the form's data is sent to the server for processing (to avoid validation errors on unrelated fields), but it does not control which part of the page is re-drawn on the client. Option B () is a way to call Apex from JavaScript but doesn't solve the button's refresh behavior directly. Implementing reRender is the standard and most efficient way to achieve the 'partial refresh' UX in Visualforce, significantly improving the perceived performance and user experience by reducing the amount of data and UI flickering during search operations.

==========


Question 4

A developer is working with existing functionality that tracks how many times a stage has changed for an Opportunity. When the Opportunity's stage is changed, a workflow rule is fired to increase the value of a field by one. The developer wrote an after trigger to create a child record when the field changes from 4 to 5. A user changes the stage of an Opportunity and manually sets the count field to 4. The count field updates to 5, but the child record is not created. What is the reason this is happening?



Answer : A

12

The issue described is rooted in the Salesforce Order of Execution. When a record is saved, Salesforce follows a very specific sequence of events. First, original triggers (before and after) are executed. Only after these triggers have completed does the system evaluate and execute workflow rules.34

In this scenario, th5e following happens:6

The user saves the Opportunity with the count set to 4.7

The After Trigger fires. At this point, the field value i8s still 4. Since the trigger logic only creates a child record when the value 'changes from 4 to 5,' and it is currently exactly 4 (not yet 5), the condition is not met.

Next, the Workflow Rule fires and performs a field update, changing the count from 4 to 5.

According to the platform rules, a workflow field update causes Before and After Triggers to fire one more time to account for the change. However, in this second execution of the after trigger, Trigger.old now contains the value 4 (from the start of the second execution) and Trigger.new contains 5. While the condition old == 4 and new == 5 is now technically true, many developers fail to realize that the first execution (before the workflow) already bypassed the logic because the workflow hadn't updated the value yet.

If the trigger was written to look for the exact transition, it might fail during the first pass (where the value is 4) and potentially execute during the second pass. However, if the logic is not specifically handled to account for the re-entrant nature of workflow field updates, or if the 'After triggers fire before workflow rules' (Option A) is the primary constraint being tested, it explains why the initial save logic didn't see the '5' until it was too late in the initial trigger context.


Question 5

Universal Containers uses a custom Lightning page to provide a mechanism to perform a step-by-step wizard search for Accounts. One of the steps in the wizard is to allow the user to input text into a text field, ERP_Number__c, that is then used in a query to find matching Accounts.

Java

erpNumber = erpNumber + '%';

List accounts = [SELECT Id, Name FROM Account WHERE ERP_Number__c LIKE :erpNumber];

A developer receives the exception 'SOQL query not selective enough'. Which step should be taken to resolve the issue?



Answer : C

The 'SOQL query not selective enough' error occurs when a query on an object with a large volume of records (typically over 200,000) does not use a filtered index to narrow down the result set effectively. In Sales1force,2 the query optimizer must be able to use an index to scan a small enough percentage of the total records to maintain performance. When a query filters on a non-indexed field, the system is forced to perform a full table scan, which triggers this exception to prevent performance degradation.

To resolve this, the developer must ensure that the field used in the WHERE clause is indexed. Marking a custom field as an 'External ID' or 'Unique' automatically creates a custom index on that field. By marking ERP_Number__c as an External ID, the platform generates a underlying database index, allowing the query optimizer to quickly locate matching records without scanning the entire table. While the LIKE operator with a trailing wildcard (e.g., 'Text%') can utilize an index, it will only be considered 'selective' if the filter narrow the results below the platform's selectivity thresholds (typically 10% of the first million records). Making the field an External ID is the standard programmatic solution to provide the necessary indexing for selectivity. Option A is incorrect because moving a non-selective query to an asynchronous process does not change the fact that it is non-selective; it will still fail.

==========


Page:    1 / 14   
Total 161 questions