Platform Developer II Sample Questions & Answers
Most questions target how triggers and automation fire in sequence plus error handling, along with base system objects, multiple languages and outside identifiers in the data model, Visualforce controllers, query tuning, web service integration, and testing practices.
Launch the full Platform Developer II simulator →Showing 10 of 20 free samples.
- Question 1Advanced
Data Modeling and Management · Custom Metadata and Custom Settings
Quantum Logistics has a complex, multi-lingual Salesforce org. They need to store configuration data for a custom shipping calculator, including shipping rates, service levels, and country-specific surcharges. This configuration data must be deployable between sandboxes and production, and it needs to be easily queryable within Apex. The data structure is relational, with 'Service Levels' being a parent to 'Country Surcharges'. What is the most appropriate solution for storing this configuration data?
Show answer & explanation
Correct answer: D
Custom Metadata Types are the best fit for this scenario. They are deployable, meaning the configuration data can be moved between environments as metadata. They can be queried using SOQL, and they support relationships, allowing the developer to model the parent-child structure between 'Service Levels' and 'Country Surcharges'. Custom Objects are data, not metadata, and are harder to deploy. Custom Settings are not as well-suited for complex relational structures and are less easily deployed.
- Question 2Advanced
Performance · Query Performance
A developer at a large enterprise is tasked with creating a nightly batch job that deactivates
Contactrecords that have not been logged into a community for over 180 days. The org contains over 10 millionContactrecords. The initial SOQL querySELECT Id FROM Contact WHERE LastLoginDate < LAST_N_DAYS:180is timing out. What is the most effective way to resolve this query performance issue?Show answer & explanation
Correct answer: B
The query is timing out because it is non-selective. It has to perform a full table scan on 10 million records to find contacts where
LastLoginDateis older than 180 days. Standard date fields likeLastLoginDateare not indexed by default. The most effective solution is to work with Salesforce Support to create a custom index on this field. This will make the query highly selective and allow it to execute efficiently without timing out. - Question 3Beginner
Data Modeling and Management · External IDs
True or False: When using the
Database.upsertmethod with an External ID field, if multiple records in the database match the provided External ID, the operation will throw a DML exception.Show answer & explanation
Correct answer: A
This statement is true. The External ID field must uniquely identify a single record for the
upsertoperation to succeed. If the value of the External ID field is not unique and matches multiple existing records, the operation will fail and aDmlExceptionwill be thrown, indicating that multiple records were found for the upsert. - Question 4Beginner
Logic and Process Automation · Declarative and Programmatic Integration
A developer needs to expose an Apex method that can be called from a Process Builder or Flow. The method should accept a list of
OpportunityIDs and perform a complex calculation that is not possible with declarative tools. Which annotation must be used for the Apex method?Show answer & explanation
Correct answer: C
The
@InvocableMethodannotation is specifically designed to expose an Apex method as a callable action in declarative tools like Process Builder, Flow, and the REST API. The method must be static and can have only one parameter, which must be a list of a primitive data type or a custom Apex class. - Question 5Advanced
Logic and Process Automation · Asynchronous Execution
A business process requires that when an Opportunity is updated, a callout is made to an external system to reserve inventory. This callout must not delay the saving of the Opportunity record. If the callout fails, it should be automatically retried up to three times. Which asynchronous Apex pattern best meets all these requirements?
Show answer & explanation
Correct answer: B
Queueable Apex is the best fit. It runs asynchronously, so it won't delay the Opportunity save. Crucially, a Queueable job can enqueue another job from within its
executemethod, which allows for complex patterns like implementing a retry mechanism. The job can maintain aretryCountstate variable and, upon failure, re-enqueue itself if the count is below the threshold.@futuremethods cannot call other@futuremethods, and Batch Apex is overkill for a single callout. - Question 6Intermediate
Logic and Process Automation · Order of Execution
A developer has an Apex trigger on the
Accountobject. This trigger calls a helper method that updates all relatedContactrecords. The same helper method is also called from a Visualforce controller. To prevent the trigger from executing recursively when the contacts are updated, what is the recommended best practice?Show answer & explanation
Correct answer: B
The standard and recommended best practice for preventing trigger recursion within a single transaction is to use a static Boolean variable. A utility class holds the static variable (e.g.,
hasAlreadyRun). The trigger checks this variable before executing its logic. If it's false, it sets it to true and runs the logic. If it's already true, it bypasses the logic, preventing the recursive call from re-executing. - Question 7Beginner
Data Modeling and Management · Multi-Language and Localization
A custom Visualforce page is used to create and edit
Project__crecords. To support international users, all labels and messages on the page must be translated. How should a developer ensure that text displayed on the page is translatable?Show answer & explanation
Correct answer: C
Custom Labels are the standard Salesforce feature for storing translatable text. By creating a Custom Label for each piece of text and referencing it in Visualforce with the syntax
$Label.MyLabelName, the platform will automatically display the correct translation based on the user's language setting, provided that translations have been entered in the Translation Workbench. - Question 8Intermediate
Integration · Web Services Exposure
A developer needs to create a custom REST API endpoint in Salesforce. The endpoint must be accessible via
GETto retrieveOrder__cdata and viaPOSTto create newOrder__crecords. Which combination of annotations is required to build this Apex REST service?Show answer & explanation
Correct answer: B
To create an Apex REST service, the class must be annotated with
@RestResource(urlMapping='/Your/Endpoint/*'). Within this class, specific methods handle different HTTP verbs. The method to handle GET requests must be annotated with@HttpGet, and the method to handle POST requests must be annotated with@HttpPost. - Question 9Intermediate
Testing · Testing Visualforce
A developer is writing a test class for a Visualforce controller extension. The extension adds logic to the standard
Accountcontroller. How can the developer instantiate the controller extension within the test method to simulate it running on a Visualforce page?Show answer & explanation
Correct answer: B
A controller extension's constructor requires an instance of
ApexPages.StandardControlleras its argument. To test it, you must first create the record the controller will be based on (e.g., anAccount). Then, you create a newApexPages.StandardControllerinstance, passing the test record to its constructor. Finally, you instantiate your extension, passing the standard controller instance to its constructor. - Question 10Advanced
Debug and Deployment Tools · Performance Analysis and Debugging
A Salesforce org is experiencing slow page load times for a custom Lightning record page. A consultant uses the Salesforce Lightning Inspector Chrome extension to diagnose the issue and discovers that a single Apex controller method, marked as
@AuraEnabled(cacheable=true), is being called multiple times with the same parameters by different components on the page. What is the most likely cause of this redundant data retrieval?Show answer & explanation
Correct answer: C
The Lightning Data Service provides client-side caching for
@AuraEnabled(cacheable=true)methods, but this is primarily leveraged when using the@wireservice. If components call the same cacheable Apex method imperatively (e.g., inconnectedCallback), the framework does not automatically deduplicate these calls. The@wireservice is designed to recognize identical requests (method and parameters) and serve subsequent requests from its client-side cache, resulting in only one server trip.
Ready for the real thing?
The full Platform Developer II simulator has every exam-style question, timed mode, and instant scoring.