Salesforce Certified Platform Developer II Exam

450 Questions and Answers

Salesforce Certified Platform Developer II Exam Answers

The Salesforce Certified Platform Developer II Exam is designed for experienced Salesforce developers who want to demonstrate their advanced skills in building complex business logic and interfaces using the Salesforce platform. This certification validates your expertise in programmatic capabilities, data modeling, integration, and advanced Apex programming.

What You Will Learn

By preparing for the Platform Developer II exam, you’ll deepen your understanding of:

  • Advanced Apex programming techniques, including asynchronous Apex, triggers, and exception handling

  • Complex data modeling and management within Salesforce

  • Integration strategies using web services and APIs

  • Implementing and testing advanced business logic

  • Security and sharing mechanisms to protect data

  • Application lifecycle management and deployment best practices

  • Design patterns and best coding practices in Apex

Who Should Take This Exam

This exam is ideal for:

  • Salesforce developers with at least 2-3 years of hands-on experience

  • Professionals who have already earned the Platform Developer I certification

  • Developers seeking to advance their career by mastering sophisticated Salesforce development concepts

  • Those responsible for designing, developing, and deploying complex Salesforce applications

Core Topics Covered

The Salesforce Certified Platform Developer II Exam covers a wide range of topics, including:

  • Apex programming and testing

  • Advanced data modeling and management

  • User interface development with Visualforce and Lightning components

  • Integration with external systems

  • Security and access control

  • Debugging and performance optimization

  • Deployment and release management

Why Choose Exam Sage for Your Preparation?

At Exam Sage, we offer comprehensive and expertly crafted practice tests tailored for the Salesforce Certified Platform Developer II exam. Our materials include:

  • Realistic exam-style multiple-choice questions

  • Detailed explanations for every answer to deepen your understanding

  • Regularly updated content to reflect the latest Salesforce platform changes

  • Easy-to-use interface for effective study sessions

Preparing with Exam Sage ensures you build confidence and readiness to pass the exam on your first try, accelerating your Salesforce developer career.

Sample Questions and Answers

1.

Which feature can be used to execute complex business logic asynchronously in Salesforce?

A) Process Builder
B) Future Methods
C) Validation Rules
D) Workflow Rules

Answer: B) Future Methods
Explanation: Future methods allow you to run processes asynchronously, which means the code runs in a separate thread from the main execution, suitable for operations like callouts or time-consuming processes.


2.

What is the primary purpose of a Queueable Apex?

A) To schedule jobs to run at a later time
B) To handle complex asynchronous processing with chaining
C) To trigger workflow rules
D) To validate data before insertion

Answer: B) To handle complex asynchronous processing with chaining
Explanation: Queueable Apex provides more flexibility than future methods, including job chaining and handling complex objects.


3.

Which method in a batch Apex class is used to process each batch of records?

A) start()
B) execute()
C) finish()
D) process()

Answer: B) execute()
Explanation: The execute method is called for each batch of records to process them in chunks.


4.

What is a key difference between with sharing and without sharing keywords in Apex?

A) with sharing ignores object permissions
B) without sharing enforces the current user’s sharing rules
C) with sharing enforces sharing rules, without sharing ignores them
D) No difference in access control

Answer: C) with sharing enforces sharing rules, without sharing ignores them
Explanation: Apex classes declared with sharing respect sharing rules of the current user, while without sharing ignores them.


5.

How can you prevent SOQL injection in Apex code?

A) Use dynamic SOQL queries without bind variables
B) Use string concatenation for queries
C) Use static SOQL with bind variables and escape user inputs
D) Use Apex REST endpoints only

Answer: C) Use static SOQL with bind variables and escape user inputs
Explanation: Bind variables prevent SOQL injection by safely inserting user inputs without concatenation.


6.

Which annotation is used to expose Apex classes and methods to Lightning Web Components?

A) @AuraEnabled
B) @RemoteAction
C) @InvocableMethod
D) @WebService

Answer: A) @AuraEnabled
Explanation: @AuraEnabled exposes Apex methods to Lightning Components and LWC.


7.

What is the maximum number of batch Apex jobs that can be queued or active at the same time?

A) 5
B) 50
C) 100
D) 200

Answer: B) 50
Explanation: Salesforce limits the number of batch Apex jobs that can be queued or active concurrently to 50.


8.

Which type of test method isolation is provided by the SeeAllData=false annotation?

A) Allows access to all org data
B) Prevents access to org data, requires data creation in test
C) Only access to User object data
D) Allows access to all custom metadata

Answer: B) Prevents access to org data, requires data creation in test
Explanation: SeeAllData=false enforces data isolation in tests, promoting best practices by requiring explicit test data setup.


9.

In an Apex trigger, what is the best way to prevent recursive trigger calls?

A) Use static Boolean variables to track execution state
B) Use process builder to control trigger execution
C) Use try-catch blocks
D) Use @future annotation

Answer: A) Use static Boolean variables to track execution state
Explanation: Static variables maintain state during the transaction and help prevent recursive trigger execution.


10.

What happens if a DML operation inside a trigger fails?

A) Only the failed record is rolled back
B) The entire trigger execution is rolled back
C) Trigger execution continues for other records
D) DML errors are ignored by default

Answer: B) The entire trigger execution is rolled back
Explanation: Salesforce treats DML errors as a transaction failure, rolling back all changes to maintain data integrity.


11.

Which interface must a class implement to be used as a batch Apex job?

A) Database.Batchable
B) Schedulable
C) Queueable
D) InvocableMethod

Answer: A) Database.Batchable
Explanation: The Database.Batchable interface defines the methods start, execute, and finish for batch jobs.


12.

Which method in the Schedulable interface contains the logic to be executed at scheduled time?

A) execute()
B) run()
C) schedule()
D) start()

Answer: A) execute()
Explanation: The execute method is called when the scheduled job runs.


13.

How can you chain multiple batch Apex jobs?

A) Call the next batch in the finish() method of the current batch
B) Use @future methods
C) Chain is not supported in batch Apex
D) Use Queueable Apex only

Answer: A) Call the next batch in the finish() method of the current batch
Explanation: The finish method is the correct place to schedule the next batch job.


14.

Which method would you use to make callouts from a batch Apex class?

A) Only from start() method
B) Only from finish() method
C) Only from execute() method with @future annotation
D) execute() method with Database.AllowsCallouts interface

Answer: D) execute() method with Database.AllowsCallouts interface
Explanation: To perform callouts in batch Apex, the class must implement Database.AllowsCallouts.


15.

Which type of test data creation improves test execution speed?

A) Using @testSetup method to create reusable test data
B) Creating test data in every test method
C) Using SeeAllData=true
D) Using real org data

Answer: A) Using @testSetup method to create reusable test data
Explanation: @testSetup creates test data once per test class, improving speed and reducing duplication.


16.

What is the best practice for bulkifying Apex triggers?

A) Process one record at a time inside trigger
B) Use collections and process records in bulk
C) Use SOQL queries inside for loops
D) Call external web services inside loops

Answer: B) Use collections and process records in bulk
Explanation: Bulkification prevents hitting governor limits by processing multiple records efficiently.


17.

Which annotation allows Apex methods to be called from Flow?

A) @InvocableMethod
B) @AuraEnabled
C) @WebService
D) @RemoteAction

Answer: A) @InvocableMethod
Explanation: @InvocableMethod exposes Apex methods to Flows and Process Builder.


18.

Which governor limit applies to synchronous Apex?

A) Total number of batch Apex jobs in the org
B) Total CPU time of 10,000 milliseconds
C) Total asynchronous SOQL queries limit
D) Maximum number of future calls

Answer: B) Total CPU time of 10,000 milliseconds
Explanation: Synchronous Apex has a CPU time limit of 10 seconds per transaction.


19.

How can you avoid hitting the “Too many SOQL queries” governor limit?

A) Use queries inside loops
B) Use collections and query outside loops
C) Query inside nested loops
D) Use SOQL in triggers only

Answer: B) Use collections and query outside loops
Explanation: Querying outside loops and using collections for IDs reduces SOQL query count.


20.

Which statement about Apex sharing recalculation is true?

A) Apex sharing recalculation cannot be invoked via Apex
B) Apex sharing recalculation runs asynchronously
C) Apex sharing recalculation runs synchronously
D) Apex sharing recalculation only applies to manual sharing

Answer: B) Apex sharing recalculation runs asynchronously
Explanation: Apex sharing recalculations run asynchronously and can be scheduled or triggered programmatically.


21.

How do you call a REST API from Apex?

A) Use HttpRequest and HttpResponse classes
B) Use @RestResource annotation only
C) Use @InvocableMethod
D) Use Database.Query

Answer: A) Use HttpRequest and HttpResponse classes
Explanation: The HttpRequest and HttpResponse classes allow Apex to perform HTTP callouts.


22.

What is a correct way to handle exceptions in Apex?

A) Use try-catch blocks and log errors or perform recovery
B) Avoid try-catch blocks and let exceptions bubble up
C) Use only System.assert for error handling
D) Ignore exceptions for better performance

Answer: A) Use try-catch blocks and log errors or perform recovery
Explanation: Proper exception handling ensures robust, maintainable code and better user experience.


23.

What is the purpose of the transient keyword in Visualforce controllers?

A) To mark variables that should not be serialized during view state saving
B) To define constants
C) To improve database performance
D) To prevent DML operations

Answer: A) To mark variables that should not be serialized during view state saving
Explanation: transient variables are excluded from the view state to reduce page size and improve performance.


24.

Which is a benefit of using Custom Metadata Types over Custom Settings?

A) Can be deployed via change sets and packaged
B) Cannot be accessed in Apex
C) Limited to user-specific data
D) Only accessible via API

Answer: A) Can be deployed via change sets and packaged
Explanation: Custom Metadata Types are metadata and can be deployed and packaged, unlike Custom Settings.


25.

Which method is used to send email asynchronously in Apex?

A) Messaging.sendEmail()
B) System.enqueueJob()
C) @future annotated method calling Messaging.sendEmail()
D) Database.insert()

Answer: C) @future annotated method calling Messaging.sendEmail()
Explanation: To send email asynchronously, call Messaging.sendEmail() inside a @future method.


26.

How can you ensure that a custom Lightning web component is only accessible to certain profiles?

A) Use Apex sharing rules
B) Control access through Lightning App Builder and profiles
C) Use @AuraEnabled and @InvocableMethod annotations
D) Use SOQL queries to filter users

Answer: B) Control access through Lightning App Builder and profiles
Explanation: Access to Lightning components can be controlled by assigning them to apps or pages with profile-based visibility.


27.

What is the effect of calling Limits.getLimitDmlStatements() in Apex?

A) Returns the number of DML statements allowed per transaction
B) Returns the number of DML statements used so far
C) Throws an exception if limits are exceeded
D) Resets the DML limits for the transaction

Answer: A) Returns the number of DML statements allowed per transaction
Explanation: getLimitDmlStatements() returns the max number of DML statements allowed (usually 150).


28.

Which Salesforce feature allows declarative automation of approval processes?

A) Approval Process
B) Workflow Rules
C) Process Builder
D) Flow Builder

Answer: A) Approval Process
Explanation: Approval processes are declarative workflows designed specifically for approval routing and tracking.


29.

Which of the following is NOT a valid return type for an @AuraEnabled Apex method called from Lightning Web Components?

A) Primitive data types (String, Integer, etc.)
B) SObject types
C) Apex classes with @AuraEnabled properties
D) Void

Answer: D) Void
Explanation: @AuraEnabled methods must return a value or be marked void only if called imperatively, but in general, void methods cannot be called from LWC expecting a return.


30.

What is the effect of marking a class as global in Apex?

A) It restricts access to the class to the current namespace only
B) It allows the class to be accessed outside the namespace, such as in managed packages
C) It makes the class private
D) It automatically exposes the class as a REST service

Answer: B) It allows the class to be accessed outside the namespace, such as in managed packages
Explanation: global classes can be accessed by other namespaces, essential for managed packages.

31.

Which interface must be implemented to create a schedulable Apex class?

A) Database.Batchable
B) Schedulable
C) Queueable
D) InvocableMethod

Answer: B) Schedulable
Explanation: Implementing the Schedulable interface requires defining the execute method, which contains the code to run at scheduled times.


32.

What is the maximum batch size you can specify when executing batch Apex?

A) 50
B) 100
C) 200
D) 500

Answer: C) 200
Explanation: The maximum batch size allowed for batch Apex is 200 records per batch.


33.

What happens if you call a @future method from another @future method?

A) It executes immediately
B) It results in a runtime exception
C) It queues both methods asynchronously
D) It executes synchronously

Answer: B) It results in a runtime exception
Explanation: You cannot call one @future method from another; Salesforce throws a System.AsyncException.


34.

Which type of relationship allows you to create a many-to-many relationship between two objects?

A) Lookup Relationship
B) Master-Detail Relationship
C) Junction Object with two Master-Detail Relationships
D) External Lookup

Answer: C) Junction Object with two Master-Detail Relationships
Explanation: A junction object with two master-detail relationships models many-to-many relationships.


35.

What is the key difference between Custom Settings and Custom Metadata Types?

A) Custom Settings are metadata, Custom Metadata Types are data
B) Custom Metadata Types are deployable and packageable, Custom Settings are not
C) Both are exactly the same
D) Custom Metadata Types cannot be queried in Apex

Answer: B) Custom Metadata Types are deployable and packageable, Custom Settings are not
Explanation: Custom Metadata Types are metadata, deployable via packages and change sets; Custom Settings are org data.


36.

Which Apex method allows you to handle uncommitted work errors during callouts?

A) @future annotated methods
B) Database.executeBatch
C) Use System.runAs()
D) Database.rollback()

Answer: A) @future annotated methods
Explanation: Callouts are not allowed after DML in the same transaction unless done asynchronously via @future.


37.

Which of the following statements about Platform Events is TRUE?

A) Platform Events are synchronous in nature
B) Platform Events use a publish-subscribe model for event-driven architecture
C) Platform Events cannot be consumed by Apex triggers
D) Platform Events are not stored in Salesforce

Answer: B) Platform Events use a publish-subscribe model for event-driven architecture
Explanation: Platform Events facilitate asynchronous event-driven communication between processes.


38.

How do you handle mixed DML operation errors when updating Setup and Non-Setup objects in the same transaction?

A) Perform all DML operations inside a single transaction
B) Use System.runAs() in test methods only
C) Separate DML operations into different transactions using @future or queueable methods
D) Use Database methods with partial success

Answer: C) Separate DML operations into different transactions using @future or queueable methods
Explanation: Mixed DML operations (between setup and non-setup objects) require separation into different transactions.


39.

Which method in Apex allows you to test asynchronous code execution?

A) Test.startTest() and Test.stopTest()
B) System.assert()
C) Test.isRunningTest()
D) System.schedule()

Answer: A) Test.startTest() and Test.stopTest()
Explanation: These methods reset governor limits and ensure asynchronous code runs synchronously during tests.


40.

Which one is NOT a valid way to handle callouts in Apex?

A) Using @future(callout=true)
B) Using Queueable Apex with Database.AllowsCallouts
C) Using synchronous Apex without any special annotation
D) Using Continuations for long-running callouts

Answer: C) Using synchronous Apex without any special annotation
Explanation: Callouts must be made asynchronously or with specific interfaces/annotations.


41.

Which statement best describes the Database.Stateful interface in batch Apex?

A) It allows sharing state between batch executions
B) It schedules the batch job
C) It prevents sharing of data between batch executions
D) It performs database operations outside batch jobs

Answer: A) It allows sharing state between batch executions
Explanation: Database.Stateful retains instance variable values between batch execute calls.


42.

What is the maximum number of records that can be returned by a SOQL query?

A) 10,000
B) 50,000
C) 100,000
D) Unlimited

Answer: B) 50,000
Explanation: SOQL queries return up to 50,000 records by default, beyond which errors occur.


43.

Which tool is recommended for migrating Custom Metadata Types between orgs?

A) Data Loader
B) Change Sets
C) Workbench
D) Force.com IDE or Metadata API

Answer: D) Force.com IDE or Metadata API
Explanation: Custom Metadata Types are metadata and best moved via Metadata API tools.


44.

Which type of Apex test method data isolation annotation allows tests to see actual org data?

A) @isTest(SeeAllData=true)
B) @testSetup
C) @isTest(SeeAllData=false)
D) None

Answer: A) @isTest(SeeAllData=true)
Explanation: SeeAllData=true allows access to existing org data, which is generally discouraged.


45.

How does System.enqueueJob() differ from @future methods?

A) System.enqueueJob() supports job chaining and complex objects
B) @future supports job chaining
C) Both are synchronous
D) System.enqueueJob() is deprecated

Answer: A) System.enqueueJob() supports job chaining and complex objects
Explanation: Queueable Apex is more flexible than future methods, supporting chaining and complex parameters.