Salesforce Certified Platform Developer Plat-Dev-201 Exam Questions

Page: 1 / 14
Total 204 questions
Question 1

A developer created a trigger on the Account object. While testing the trigger, the developer sees the error message 'Maximum trigger depth exceeded'.

What could be the possible causes?



Answer : D

Maximum Trigger Depth Exceeded:

This error occurs when a trigger causes recursive calls, leading to an infinite loop of execution.

Solution:

Use static variables in helper classes to prevent recursive trigger execution.

Example:

public class TriggerHelper {

public static Boolean isTriggerExecuted = false;

}

trigger AccountTrigger on Account (after update) {

if (!TriggerHelper.isTriggerExecuted) {

TriggerHelper.isTriggerExecuted = true;

// Trigger logic here

}

}

Why Not Other Options?

A: Permissions do not affect trigger recursion.

B: Length of the trigger is unrelated to recursion.

C: Code coverage does not influence runtime errors like recursion.


Question 2

A developer needs to prevent the creation of Request__c records when certain conditions exist in the system. A RequestLogic class exists that checks the conditions.

What is the correct implementation?



Answer : B

Comprehensive and Detailed Explanation From Exact Extract: When preventing the creation of records using business logic in an Apex trigger, it's crucial to do it in a before insert trigger context so the records are not committed to the database. The method should be called using trigger.new (case-sensitive) which references the list of new records being inserted.


Triggers and Order of Execution

Apex Trigger Context Variables

Question 3

As part of new feature development, a developer is asked to build a responsive application capable of responding to touch events, that will be executed on stateful clients.

Which two technologies are built on a framework that fully supports the business requirement? Choose 2 answers



Answer : A, D

Lightning Web Components (LWC):

Fully responsive and designed to handle touch events.

Executes on stateful clients with high performance.

Aura Components:

Supports responsive designs and touch events but is slightly less efficient than LWC.

Why Not Other Options?

B . Visualforce Components: Not designed for responsiveness or touch event handling.

C . Visualforce Pages: Primarily server-rendered and not stateful for touch interactions.


Question 4

What are three capabilities of the tag when loading JavaScript resources in Aura components?

Choose 3 answers



Answer : A, D, E

Option A: The<ltng:require>tag ensures that scripts are loaded only once, even if referenced multiple times.

Option D: The tag allows you to specify the order of scripts to ensure dependencies are loaded correctly.

Option E: Externally hosted scripts can be loaded using thescriptsattribute.

Not Suitable:

Option B (Loading scripts in parallel): Scripts are loaded sequentially to ensure proper dependency handling.

Option C (Loading Files from Documents): Files must be hosted externally or in static resources, not in Documents.

:ltng:require Documentation


Question 5

A developer has an integer variable called maxAttempts. The developer needs to ensure that once maxAttempts is initialized, it preserves its value for the length of the Apex transaction; while being able to share the variable's state between trigger executions.

How should the developer declare maxAttempts to meet these requirements?



Answer : D

To preserve the value ofmaxAttemptsfor the length of the Apex transaction and share its state between trigger executions:

Static Variable:

Static variables are initialized once per transaction and retain their value throughout the transaction.

They can be accessed without instantiating the class.

Private Scope:

Declaring it as private ensures encapsulation and prevents unintended external modification.

Helper Class:

Using a helper class ensures the separation of concerns, keeping trigger logic clean and adhering to best practices.

Example Code:public class HelperClass {

private static Integer maxAttempts = 5; // Default value

public static Integer getMaxAttempts() {

return maxAttempts;

}

public static void setMaxAttempts(Integer attempts) {

maxAttempts = attempts;

}

}

A:Constants (static + final) cannot be modified after initialization.

B:Trigger member variables cannot retain values across executions within the same transaction.

C:Declaring it as a non-static variable in a helper class would reset its value during each trigger execution.

Why Not the Other Options?


Question 6

What is the result of the following code?



Answer : A

Based on the provided code, an exception is likely being thrown if a required field is missing or if there are validation rules that the record does not meet. Salesforce will throw an exception when an attempt to create a record violates constraints.

Why not other options?

B: Salesforce reports errors for failed DML operations unless they are handled in atry-catchblock.

C: The record cannot be created successfully if constraints are violated.

D: Debug logs may provide details, but the record creation would fail.

:

Apex DML Exception Handling


Question 7

A developer is integrating with a legacy on-premise SQL database.

What should the developer use to ensure the data being integrated is matched to the right records in Salesforce?



Answer : B

AnExternal ID fieldis used to match data in Salesforce with data from external systems (like an on-premise SQL database). It allows for easy upserts and data integration without relying on Salesforce IDs.

Why not other options?

A: External objects are used for real-time integration with external systems but do not address data matching directly.

C: Formula fields are calculated fields and cannot be used for data matching.

D: Lookup fields are used for creating relationships between objects within Salesforce, not for matching external data.


Page:    1 / 14   
Total 204 questions