Certified Platform Developer II Practice Exam Free – 50 Questions to Simulate the Real Exam
Are you getting ready for the Certified Platform Developer II certification? Take your preparation to the next level with our Certified Platform Developer II Practice Exam Free – a carefully designed set of 50 realistic exam-style questions to help you evaluate your knowledge and boost your confidence.
Using a Certified Platform Developer II practice exam free is one of the best ways to:
- Experience the format and difficulty of the real exam
- Identify your strengths and focus on weak areas
- Improve your test-taking speed and accuracy
Below, you will find 50 realistic Certified Platform Developer II practice exam free questions covering key exam topics. Each question reflects the structure and challenge of the actual exam.
A company's support process dictates that any time a Case is closed with a Status of 'Could not fix', an Engineering Review custom object record should be created and populated with information from the Case, the Contact, and any of the Products associated with the Case. What is the correct way to automate this using an Apex trigger?
A. An after update trigger that creates the Engineering Review record and inserts it
B. A before update trigger that creates the Engineering Review record and inserts it
C. An after upsert trigger that creates the Engineering Review record and inserts it
D. A before upsert trigger that creates the Engineering Review record and inserts it
A developer created a custom component to display an HTML table. The developer wants to be able to use the component on different Visualforce Pages and specify different header text for the table. Which tag should the developer use inside the component?
A.
B.
C.
D.
A Lightning Component functions in preview mode and needs to be used inside a Lightning App Builder page, but it is not available. What change should be applied to the component?
A. Expose it in the markup using the implements and access attributes.
B. Delete the component, metadata, and Apex controller and recreate them.
C. Refresh the sandbox and upgrade it to the latest API version.
D. Look for errors in the logic in the JavaScript controller.
A company has the Lightning Component above that allows users to click a button to save their changes and redirects them to a different page. Currently, when the user hits the Save button the records are getting saved, but they are not redirected. Which three techniques can a developer use to debug the JavaScript? (Choose three.)
A. Enable Debug Mode for Lightning components for the user.
B. Use console.log() messages in the JavaScript.
C. Use Developer Console to view debug log.
D. Use the browser’s dev tools to debug the JavaScript.
E. Use Developer Console to view checkpoints.
Which API can be used to execute unit tests? (Choose three.)
A. Streaming API
B. Test API
C. Tooling API
D. SOAP API
E. Metadata API
A developer is trying to access org data from within a test class. Which sObject type requires the test class to have the (seeAllData=true) annotation?
A. Report
B. User
C. Profile
D. RecordType
A developer is trying to decide between creating a Visualforce component or a Lightning component for a custom screen. Which functionality consideration impacts the final decision?
A. Does the screen need to be rendered as a PDF?
B. Does the screen need to be accessible from the Lightning Experience UI?
C. Will the screen make use of a JavaScript framework?
D. Will the screen be accessed via a mobile app?
A developer sees test failures in the sandbox but not in production. No code or metadata changes have been actively made to either environment since the sandbox was created. Which consideration should be checked to resolve the issue?
A. Ensure the sandbox is on the same release as production.
B. Ensure Workflow Rules are inactive.
C. Ensure the Apex Classes are on the same API version.
D. Ensure Process Builder processes are inactive.
What is a consideration when using bind variables with dynamic SOQL? (Choose two.)
A. Dynamic SOQL cannot reference fields on bind variables
B. Dynamic SOQL cannot use bind variables
C. Bind variables must be public or global
D. Bind variables must be in local scope
A developer has been asked to create code that will meet the following requirements: Receives input of: Map<Id, Project_c), List Performs a potentially long-running callout to an outside web service Provides a way to confirm that the process executed successfully Which asynchronous feature should be used?
A. @future (callout=true)
B. Database.AllowCallouts interface
C. Schedulable interface
D. Queueable interface
@isTest static void testIncrement() { Account acct = new Account(Name = 'Test'); acct.Number_Of_Times_Viewed__c = 0; insert acct; AuditUtil.incrementViewed(acct.Id); Account acctAfter = [SELECT Number_Of_Times_Viewed__c FROM Account WHERE Id = :acct.Id][0] System.assertEquals(1, acctAfter.Number_Of_Times_Viewed__c); } The test method above calls an @future method that increments the Number_of_Times_Viewed__c value. The assertion is failing because the Number_of_Times_Viewed__c equals 0. What is the optimal way to fix this?
A. Change the initialization to acct.Number_Of_Times_Viewed__c = 1.
B. Add Test.startTest() before and Test.stopTest() after AuditUtil.incrementViewed.
C. Add Test.startTest() before and Test.stopTest() after insert acct.
D. Change the assertion to System.assertEquals(0, acctAfter.Number_Of_Times_Viewed__c).
Which statement is considered a best practice for writing bulk safe Apex Triggers?
A. Add records to collections and perform DML operations against these collections
B. Instead of DML statements, use the Database methods with allOrNone set to False
C. Add LIMIT 50000 to every SOQL statement
D. Perform all DML operations from within a Future Method
An org has a requirement that the Shipping Address on the Account must be validated by a third-party web service, before the Account is allowed to be inserted. This validation must happen in real-time before the account is inserted into the system. Additionally, the developer wants to prevent the consumption of unnecessary SME statements. What is the optimal way to meet this requirement?
A. Make a callout to the web service from a custom Visualforce controller.
B. Make a callout to the web service from a before insert trigger.
C. Make a callout to the web service from a standard Visualforce controller.
D. Make a callout to the web service from an after insert trigger.
A company has reference data stored in multiple custom metadata records that represent default information and delete behavior for certain geographic regions. When a contact is inserted, the default information should be set on the contact from the custom metadata records based on the contact's address information. Additionally, if a user attempts to delete a contact that belongs to a flagged region, the user must get an error message. What is the optimal way to automate this?
A. Apex invocable method
B. Remote action
C. Flow Builder
D. Apex trigger
A company processes Orders within their Salesforce instance. When an Order's status changes to 'Paid' it must notify the company's order management system (OMS). The OMS exposes SOAP web service endpoints to listen for when to retrieve the data from Salesforce. What is the optimal method to implement this?
A. Generate the Enterprise WSDL and use it to make a callout to the OMS.
B. Generate the Partner WSDL and use it to make a callout to the OMS.
C. Create an Outbound Message that contains the session ID and send it to the OMS.
D. Create an Apex trigger and make a callout to the OMS from the trigger.
A developer is working on code that requires a call to an external web service from a batch. How should the developer enable this functionality?
A. Implement a custom System.CalloutException class
B. Include Database.AllowCallout() in the class definition
C. Implement an @future method for the callout, and invoke it from the batch
D. Specify “callout=true” in the batch implementation
A company has a custom object, Request_c, that has a checkbox field, Completed_c, and a Lookup to Opportunity, Opportunity_c. Which SOQL query will get a unique list of all of the Opportunity records that have a Completed Request?
A. SELECT Opportunity_c FROM Request_c WHERE Id IN (SELECT Id FROM Request_c Where Completed_c = true)
B. SELECT Opportunity_c FROM Request_c WHERE Completed_c = true
C. SELECT Id FROM Opportunity WHERE Id IN (SELECT Id FROM Request_c WHERE Completed = true)
D. SELECT Id From Opportunity WHERE Id IN (SELECT Opportunity_c FROM Request_c WHERE Completed_c = true)
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.)
A. Example 1
B. Example 2
C. Example 3
D. Example 4
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?
A. upsert orders;
B. upsert orders Order_Number__c;
C. merge orders Order_Number__c;
D. merge orders;
Refer to the code below:A developer is building this Aura component to display information about top Opportunities in the org. Which three code changes must be made for the component to work? (Choose three.)
A. Add the static keyword to the Apex method.
B. Add the RemoteAction annotation to the Apex method.
C. Set the controller in the component markup.
D. Get the controller action with cmp.get(“OppController.getTopOpps”).
E. Add the AuraEnabled annotation to the Apex method.
During the order of execution of a Visualforce page GET request, what happens after this step? Evaluate constructors on controllers and extensions
A. Evaluate constructors and expressions on custom components
B. Create view state if exists
C. Send the HTML response to the browser
D. Evaluate expressions, action attributes, and method calls
An org has a requirement that addresses on Contacts and Accounts should be normalized to a company standard by Apex code any time that they are saved. What is the optimal way to implement this?
A. Apex trigger on Contact that calls the Account trigger to normalize the address
B. Apex triggers on Contact and Account that normalize the address
C. Apex trigger on Account that calls the Contact trigger to normalize the address
D. Apex triggers on Contact and Account that call a helper class to normalize the address
Consider the following code snippet:Which two best practices should the developer implement to optimize this code? (Choose two.)
A. Query the Pricing_Structure__c records outside of the loop.
B. Use a collection for the DML statement.
C. Change the trigger context to after update, after insert.
D. Remove the DML statement.
A developer wrote an Apex class to make several callouts to an external system. If the URLs used in these callouts will change often, which feature should the developer use to minimize changes needed to the Apex class?
A. Remote Site Settings
B. Session Id
C. Named Credentials
D. Connected Apps
A company has many different unit test methods that create Account records as part of their data setup. A new required field was added to the Account and now all of the unit tests fail. What is the optimal way for a developer to fix the issue?
A. Add a before insert trigger on Account to set the value of the required field.
B. Create a TestDataFactory class that serves as the single place to create Accounts for unit tests and set the required field there.
C. Change the required field to be a validation rule that excludes the System Administrator profile.
D. Add the required field to the data setup for all of the unit tests.
A developer is writing unit tests for the following method: public static Boolean isFreezing(String celsiusTemp){ if(String.isNotBlank(celsiusTemp) && celsiusTemp.isNumeric()) { return Decimal.valueof(celsiusTemp) <= 0; } return null; } Which assertion would be used in a negative test case?
A. System.assertEquals(true, isFreezing(null))
B. System.assertEquals (true, isFreezing('0')
C. System.assertEquals(null, isFreezing('asdf'))
D. System.assertEquals(true, isFreezing('IOO'))
A company wants to build a custom Lightning Component that will display a specified Account Field Set and that can only be added to the Account record page. Which design resource configuration should be used?
A. FieldSet
B. Account
C. FieldSet
D. Account
A developer wants to retrieve and deploy metadata, perform simple CSV export of query results, and debug Apex REST calls by viewing JSON responses. Which tool should the developer use?
A. Developer Console
B. Force.com Migration Tool
C. Workbench
D. Force.com IDE
Refer to the code below:When the code runs, it results in a System Limit Exception with the error message: Apex heap size too large. What should be done to fix this error?
A. Use a SOQL for loop to process the data.
B. Convert the List into a Set.
C. Use Limits.getLimitHeapSize().
D. Use a try/catch block to catch the error.
Universal Containers (UC) calculates commissions on their Opportunities in different ways base on complex rules that vary depending on the line of business of the Opportunity. Whenever a new line of business is added to Salesforce at UC, it is likely that a different calculation will need to be added too. When an Opportunity's stage is changed to Closed/Won, its commission should be calculated in real time. What should a developer use so that different implementations of the commission calculation can be invoked on the stage change?
A. An Apex class with a custom enum
B. A final class with multiple methods
C. An interface and implementing classes
D. Apex Describe Schema methods
A developer wrote the following method to find all the test accounts in the org:However, the test method below fails.
What should be used to fix this failing test?
A. Test.loadData to set up expected data
B. @isTear(SeeAllData=true) to access org data for the test
C. Test.fixedSearchResults() method to set up expected data
D. @testSetup method to set up expected data
A company exposes a REST web service and wants to establish two-way SSL between Salesforce and the REST web service. A certificate signed by an appropriate certificate authority has been provided to the developer. What modification is necessary on the Salesforce side? (Choose two.)
A. Create an entry for the certificate in Certificate and Key Management
B. Update the code to use HttpRequest.setClientCertificateName()
C. Configure two-factor authentication with the provided certificate
D. Update the code to use HttpRequest.setHeader() to set an Authorization header
A developer must perform a complex SOQL query that joins two objects in a Lightning component. How can the Lightning component execute the query?
A. Invoke an Apex class with the method annotated as @AuraEnabled to perform the query
B. Use the Salesforce Streaming API to perform the SOQL query
C. Create a Process Builder to execute the query and invoke from the Lightning component
D. Write the query in a custom Lightning web component wrapper and invoke from the Lightning component
Which two scenarios require an Apex method to be called imperatively from a Lightning web component? (Choose two.)
A. Calling a method that makes a web service callout
B. Calling a method that is not annotated with cacheable=true
C. Calling a method with the click of a button
D. Calling a method that is external to the main controller for the Lightning web component
A developer has created a Lightning web component that uses the getRecord wire adapter. Which three things should the developer do in a Jest test to validate the wire method is working as expected? (Choose three.)
A. Use an assert statement to validate results.
B. Import wire from lwc.
C. Use the emit() API.
D. Create a JSON file with mock data.
E. Import getRecord from lightning/uiRecordApi.
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 statusMap = new Map{‘Customer’=>’Active’, ‘Prospect’=>’Pending’} List 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 statusMap = new Map{‘Customer’=>’Active’, ‘Prospect’=>’Pending’} List 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); } update accountUpdates;
C. List 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 accountUpdates = new List<Account>(); for ( Account a : [SELECT Id, Type FROM Account]){ a.Status = a.Type == 'Customer' ? 'Active' : 'Pending'; accountUpdates.add(a); } update accountUpdates;
A company accepts orders for customers in their enterprise resource planning (ERP) system that must be integrated into Salesforce as Order__c records with a lookup field to Account. The Account object has an external ID field, ERP_Customer_ID__c. What should the integration use to create new Order__c records that will automatically be related to the correct Account?
A. Insert on the Order__c object followed by an update on the Order__c object.
B. Merge on the Order__c object and specify the ERP_Customer_ID__c for the Account relationship.
C. Upsert on the Order__c object and specify the ERP_Customer_ID__c for the Account relationship.
D. Upsert on the Account and specify the ERP_Customer_ID__c for the relationship.
A developer created and tested a Visualforce page in their developer sandbox, but now receives reports that users are encountering ViewState errors when using it in Production. What should the developer ensure to correct these errors?
A. Ensure queries do not exceed governor limits.
B. Ensure properties are marked as Transient.
C. Ensure properties are marked as private.
D. Ensure profiles have access to the Visualforce page.
A developer must create a custom pagination solution for accessing approximately 2000 records and displaying 50 records on each page. Data from Salesforce will be accessed via an API and not via Apex. How can the developer meet these requirements? (Choose two.)
A. Use a StandardSetController
B. Use CURSOR 50 in SOQL queries
C. Use OFFSET in SOQL queries
D. Use LIMIT 50 in SOQL queries
When testing batch classes, what must a developer do? (Choose two.)
A. Use seeAllData=true
B. Encapsulate code in Test.startTest() and Test.stopTest()
C. Call the class’ “execute” method
D. Limit the amount of records you test to < 200
A developer wants to call an Apex Server-side Controller from a Lightning Aura Component. What are two limitations to the data being returned by the Controller? (Choose two.)
A. A custom Apex Class can be returned, but only the values of public instance properties and methods annotated with @AuraEnabled are serialized and returned.
B. Lists of Custom Apex Classes cannot be returned by Apex Controllers called by Lightning Aura Components.
C. Basic data types are supported, but defaults, such as maximum size for a number, are defined by the objects that they map to.
D. Only Basic data types and sObjects are supported as return types for Apex Controllers called by Lightning Aura Components.
The progress of an apex job queued is using the System.enqueueJob method and needs to be monitored. Which options are valid? (Choose two.)
A. Use the Apex Jobs page in setup
B. Query the Queueable Apex record
C. Query the AsyncApexJob record
D. Use the Scheduled Jobs page in setup
Refer to the code snippet below:A custom object called Credit_Memo_c exists in a Salesforce environment. As part of a new feature development that retrieves and manipulates this type of record, the developer needs to ensure race conditions are prevented when a set of records are modified within an Apex transaction. In the preceding Apex code, how can the developer alter the query statement to use SOQL features to prevent race conditions within a transaction?
A. [Select Id, Name, Amount_c FROM Credit_Memo_c WHERE Customer_Id_c = :customerId LIMIT 50 FOR VIEW]
B. [Select Id, Name, Amount_c FROM Credit_Memo_c WHERE Customer_Id_c = :customerId LIMIT 50 FOR UPDATE]
C. [Select Id, Name, Amount_c FROM Credit_Memo_c WHERE Customer_Id_c = :customerId USING SCOPE LIMIT 50]
D. [Select Id, Name, Amount_c FROM Credit_Memo_c WHERE Customer_Id_c = :customerId LIMIT 50 FOR REFERENCE]
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?
A. After triggers fire before workflow rules.
B. Trigger.new does not change after a field update.
C. After triggers are not fired after field updates.
D. Trigger.old does not contain the updated value of the count field.
What are three benefits of using declarative customizations over code? (Choose three.)
A. Declarative customizations cannot generate run time errors.
B. Declarative customizations will automatically update with each Salesforce release.
C. Declarative customizations do not require user testing.
D. Declarative customizations are not subject to governor limits.
E. Declarative customizations generally require less maintenance.
Consider the following code snippet: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 the section identified with opportunityList is re-drawn on the screen?
A. Enclose the DATA table within the tag.
B. Ensure the action method search returns null.
C. Implement the tag with immediate = true.
F. Implement the reRender attribute on the tag.
What is the most efficient way in Visualforce to show information based on data filters defined by an end-user for a large volume of data?
A. Use the rendered condition in Visualforce to limit data based on data filters
B. Use filter conditions in a SOQL query to limit data based on data filters
C. Use an Apex controller to refine raw data based on data filters and store the result in a transient variable
D. Use an Apex controller to refine raw data based on data filters and store the result in a static variable
Which of the following annotations is the right way to invoke a single apex method?
A. @InvokableMethod()
B. @InvokableAction()
C. @InvokableApex()
As part of a new integration, a developer is asked to implement a new custom search functionality that is capable of performing unrestricted queries and can account for all values within a custom picklist field, Type__c, on the Opportunity object. The search feature must also account for NULL values. The organization-wide default for the Opportunity object is set to Public Read-Only, and a new custom index has been created for the Type__c field. There are more than 5 million Opportunity records within the environment, and a considerable amount of the existing records have NULL values for the picklist. Which technique should the developer implement to maximize performance when querying NULL values?
A. Use a SOSL query to return ALL opportunities that have a value of NULL in any field.
B. Use the OR operator to combine WHERE clauses to strictly search for each value within the picklist, including Type__c = NULL.
C. Perform two SOQL queries; one to query Opportunities where Type__c != NULL, and another to query where Type__c = NULL, then join the result set using Apex.
D. Create a formula field that substitutes NULL values for a string of text, create an index for the formula field, then use the formula within the WHERE clause.
A developer has a requirement to query three fields (Id, Name, Type) from an Account; and first and last names for all Contacts associated with the Account. Which option is the preferred, optimized method to achieve this for the Account named 'Ozone Electronics'?
A.
B.
C.
D.
Free Access Full Certified Platform Developer II Practice Exam Free
Looking for additional practice? Click here to access a full set of Certified Platform Developer II practice exam free questions and continue building your skills across all exam domains.
Our question sets are updated regularly to ensure they stay aligned with the latest exam objectives—so be sure to visit often!
Good luck with your Certified Platform Developer II certification journey!