Courseiva

Salesforce Certified Platform Developer I (SALESFORCE-PD1) (SALESFORCE-PD1) — Questions 301–345

345 questions total · 5 pages · All types, answers revealed

Page 4

Page 5 of 5

301
MCQhard

A developer is working with a Lightning Web Component and needs to ensure reactive updates occur when an object property or array element changes inside a tracked property. What is the correct approach in modern LWC?

A.Reassign the property reference (e.g., this.myObj = {...this.myObj}).
B.Use @track on every inner property.
C.Call component.forceUpdate().
D.Mutate the nested property directly; LWC automatically deep-tracks all mutations.
AnswerA

Lightning Web Components use a shallow reactivity track for properties decorated with `@track`. When mutating nested properties of an object or elements within an array, the framework does not automatically detect deep mutations because observing every nested level would degrade runtime performance. Reassigning the entire object reference forces the component's reactive engine to evaluate the change and trigger a re-render, directly satisfying the requirement for reactive updates when internal properties of a tracked object or array shift.

Why this answer

Assigning a new object or array reference (mutation via replacement) triggers reactivity in LWC tracked properties.

302
MCQhard

A batch Apex class processes 50,000 records. During the execute method, a custom governor limit is approached. Which method can the developer call to check the remaining CPU time dynamically?

A.System.getCPU()
B.AsyncApexJob.getCpuTime()
C.BatchContext.getCpuTime()
D.Limits.getCpuTime()
AnswerD

`Limits.getCpuTime()` dynamically returns the current CPU time consumed in milliseconds within the transaction, satisfying the requirement to monitor and manage the strict CPU time governor limit during heavy batch processing. By calling this method inside the `execute()` method, a developer can programmatically evaluate resource consumption against the platform's synchronous or asynchronous execution thresholds. This enables proactive logic branching, such as deferring remaining work to subsequent iterations or streamlining complex calculations to prevent unhandled `LimitException` faults when processing large volumes of records.

Why this answer

Limits.getLimitCpuTime() and Limits.getCpuTime() allow developers to monitor resource usage dynamically.

303
MCQmedium

An Apex trigger needs to check whether the current user has read access to the 'AnnualRevenue' field on the Account object before performing a calculation. Which method should the developer use?

A.Schema.sObjectType.Account.fields.AnnualRevenue.getDescribe().isAccessible()
B.User.hasReadAccess('Account', 'AnnualRevenue')
C.Account.AnnualRevenue.getDescribe().isAccessible()
D.System.checkFieldAccess(Account.class, 'AnnualRevenue', 'Read')
AnswerA

Traversing the sObject schema hierarchy via `Schema.sObjectType.Account.fields.AnnualRevenue.getDescribe()` accesses the field-level metadata natively within Apex. Calling the `.isAccessible()` method on this description object evaluates the running user's runtime field-level security permissions, satisfying the stem's requirement to check read access on the 'AnnualRevenue' field prior to executing the calculation.

Why this answer

Schema.sObjectType.Account.fields.AnnualRevenue.getDescribe().isAccessible() checks field-level security for the current user in Apex.

304
MCQmedium

A developer is building a solution that requires complex branching logic. When should the developer choose Apex over Flow?

A.When complex procedural logic is needed
B.When updating fields
C.When using standard objects
D.When sending emails
AnswerA

Apex provides object-oriented programming constructs such as loops, switch statements, nested if-else blocks, and custom exception handling, which directly satisfy the requirement for complex procedural logic. While Flow can manage branching pathways through decision elements, deeply nested and intricate algorithmic branching becomes difficult to maintain visually. Procedural code handles complex, multi-variable conditional evaluations more efficiently by executing sequential instructions within a strongly typed environment, making Apex the appropriate choice for sophisticated programmatic workflows.

Why this answer

Apex should be used when complex logic is required that cannot be represented in the Flow canvas, such as complex loops or high-performance algorithms.

305
Multi-Selecthard

Which THREE design patterns or tools help ensure secure coding practices regarding CRUD and FLS in Apex? Choose 3 options.

Select 3 answers
A.Using Security.stripInaccessible() before upserting data.
B.Adding WITH SECURITY_ENFORCED to SOQL queries.
C.Performing explicit Schema describe checks (e.g., isAccessible()).
D.Declaring every class with 'without sharing'.
E.Relying solely on Lightning Web Component HTML rendering tags.
AnswersA, B, C

`Security.stripInaccessible()` directly satisfies the requirement to enforce object- and field-level security (FLS) dynamically in Apex by automatically stripping inaccessible fields and sObjects from query and subquery results, or before performing DML operations like upserts. By inspecting the running user's permissions against the schema at runtime, this built-in method prevents unauthorised data exposure and insecure mutations without throwing exceptions, making it an essential tool for secure coding practices regarding CRUD and FLS compliance.

Why this answer

Option A is correct because Security.stripInaccessible() programmatically removes fields the running user cannot create or update (based on CRUD/FLS) from sObjects before a DML operation such as upsert, preventing unauthorized field writes. Option B is correct because adding WITH SECURITY_ENFORCED to a SOQL query enforces field- and object-level security at query time, throwing an exception if the user lacks access to any referenced field or object. Option C is correct because explicit Schema describe checks like Schema.sObjectType.Account.fields.Name.isAccessible() (and isCreateable()/isUpdateable()) let developers enforce FLS/CRUD manually before reading or writing data.

Option D is incorrect because declaring classes 'without sharing' bypasses record-level sharing and does nothing to enforce CRUD or FLS, weakening security. Option E is incorrect because LWC HTML rendering tags only affect client-side display and cannot enforce server-side CRUD/FLS in Apex.

306
MCQhard

A developer is implementing a Lightning Web Component that handles drag-and-drop functionality. Which native DOM event is typically intercepted to allow a drop action on an element?

A.dragstart
B.dropstart
C.dragover and preventDefault()
D.mousedown
AnswerC

To successfully implement a drag-and-drop workflow within a Lightning Web Component, developers must intercept the native `dragover` DOM event. By default, browsers prevent elements from acting as valid drop targets. Calling `preventDefault()` within a `dragover` event handler overrides this browser restriction, satisfying the stem's requirement to explicitly permit a drop action on a specific element.

Why this answer

To allow a drop on an element, the developer must intercept the 'dragover' event and call preventDefault() on it. By default, browsers do not allow dropping on an element; calling preventDefault() in the dragover handler signals that the element is a valid drop target, after which the 'drop' event fires. This is the standard HTML5 drag-and-drop contract.

Exam trap

Salesforce-PD1 often tests the HTML5 drag-and-drop contract — the trap is picking 'dragstart' (the source event) instead of 'dragover' + preventDefault() (the target-side requirement to enable dropping).

How to eliminate wrong answers

Option A is wrong because 'dragstart' fires on the source element when the drag begins, not on the drop target, and it does not enable dropping. Option B is wrong because 'dropstart' is not a native DOM event — it is a fabricated name that does not exist in the HTML5 drag-and-drop API. Option D is wrong because 'mousedown' is a pointer event unrelated to drag-and-drop; it fires when a mouse button is pressed but does not participate in the drag lifecycle.

307
Multi-Selectmedium

Which TWO of the following statements about Trigger.new and Trigger.old are accurate?

Select 2 answers
A.Trigger.old is available in insert triggers
B.Trigger.old is available in update triggers
C.Trigger.newMap is available in before insert
D.Trigger.new is available in delete triggers
E.Trigger.new is available in update triggers
AnswersB, E

`Trigger.old` provides a read-only collection of sObject records representing their state prior to the DML operation, making it accessible exclusively within update and delete contexts. In an update trigger, this context variable is vital because it exposes the pre-values of fields, allowing developers to compare existing database values against the incoming modifications found in `Trigger.new`. Without this contextual availability, implementing validation rules or differential logic based on prior record states would be impossible.

Why this answer

Trigger.new is always present on insert/update; Trigger.old is always present on update/delete.

308
MCQeasy

Which type of Apex trigger context variable returns a list of new versions of the sObject records?

A.Trigger.new
B.Trigger.newMap
C.Trigger.old
D.Trigger.caller
AnswerA

`Trigger.new` directly satisfies the requirement specified in the stem by returning a collection of sObject records that represent the updated or newly created versions of the records in question. This context variable provides in-memory access to the incoming records during before and after insert, update, and undelete trigger executions, allowing developers to inspect and manipulate field values prior to database operations or subsequent execution logic.

Why this answer

Trigger.new contains all the new versions of the sObject records for insert and update triggers.

309
MCQhard

When testing a trigger, why should you avoid hard-coding IDs?

A.It violates Apex syntax rules.
B.It limits the test to only one record.
C.It triggers governor limits.
D.IDs change between orgs, causing test failures.
AnswerD

Salesforce record IDs are dynamically generated and unique to each environment upon record creation, meaning a hard-coded ID in a test method will not exist when you deploy or **practise** deployment to another sandbox or production org. This variability directly violates the requirement to avoid hard-coded IDs, as queries referencing static identifiers will return null results and trigger failures during test execution.

Why this answer

Record IDs are org-specific—the same logical record has different 15/18-character IDs in each Salesforce org (sandbox, production, scratch org). Hard-coding an ID in a test method means the test will fail when deployed to another org because that ID does not exist there. Tests must query for or create records dynamically to obtain valid IDs at runtime.

Exam trap

The trap is focusing on syntax or limits—candidates may think hard-coded IDs cause compilation or governor issues, but the real problem is org-specific ID portability across environments.

How to eliminate wrong answers

Option A is wrong because hard-coding an ID does not violate Apex syntax—it compiles fine; the problem is runtime portability, not syntax. Option B is wrong because hard-coding an ID does not inherently limit the test to one record; you could hard-code multiple IDs, though the portability issue remains. Option C is wrong because hard-coding an ID does not trigger governor limits—limits are about query/DML counts, not literal values.

310
MCQeasy

Which trigger context variable returns a map of IDs to the new versions of the sObject records?

A.Trigger.newMap
B.Trigger.old
C.Trigger.new
D.Trigger.oldMap
AnswerA

Trigger.newMap returns a Map<Id, sObject> keyed by record ID, with values holding the new versions of each sObject in the trigger batch. It satisfies the stem's need to correlate IDs to incoming record state, unlike Trigger.new, which is an unordered list.

Why this answer

Trigger.newMap contains the map of IDs to the new versions of the sObject records, available only in update, undelete, and after insert contexts.

311
MCQhard

A developer is writing an Aura component and needs to dynamically create a component at runtime. Which JavaScript method should be used?

A.document.createElement()
B.$A.createComponent()
C.Aura.create()
D.component.new()
AnswerB

Dynamic component instantiation in Aura requires `$A.createComponent()`, which directly satisfies the requirement to create components programmatically at runtime rather than declaratively in markup. This asynchronous framework method accepts the component descriptor, attribute definitions, and a callback function that handles the newly instantiated component once it is successfully created in memory. By executing this method within a controller or helper, developers can construct complex user interfaces dynamically based on user interaction or conditional logic.

Why this answer

$A.createComponent() is the Aura framework's factory method for dynamically instantiating a component at runtime by name, returning a callback with the new component instance that can then be inserted into the DOM via component.set('v.body', ...). It is the only supported way to create Aura components programmatically rather than declaratively in markup.

Exam trap

The trap is confusing native DOM creation (document.createElement) or made-up framework methods with the actual Aura factory API — candidates who haven't written dynamic Aura code often guess at a plausible-sounding method name instead of recalling $A.createComponent().

How to eliminate wrong answers

Option A is wrong because document.createElement() is a native DOM API that creates plain HTML elements, not Aura components — it bypasses the Aura framework entirely and cannot instantiate a component with its own controller, renderer, or attributes. Option C is wrong because Aura.create() is not a real API; the Aura namespace does not expose a create() method for component instantiation. Option D is wrong because component.new() does not exist — components are created through the $A global's createComponent() (or createComponents() for multiple), not through an instance method on an existing component.

312
MCQhard

An Apex trigger processes a large volume of Opportunity updates. The developer uses Database.update(opps, false) to allow partial success. How should the developer inspect the results to handle any failures?

A.Inspect the Trigger.errors context variable.
B.Wrap the Database.update call in a try-catch block and inspect the DMLException methods.
C.Iterate over the returned List<Database.SaveResult> and check the isSuccess() method.
D.Query the AsyncApexJob object to check for error logs.
AnswerC

Using `Database.update(opps, false)` returns a collection of `Database.SaveResult` objects that correspond directly to the input records. To handle failures properly during bulk processing, the developer must iterate through this returned list and invoke the `isSuccess()` method on each instance. This satisfies the requirement to inspect partial success results without causing unhandled exceptions, allowing the code to isolate and log specific error messages using `getErrors()` for any failed records.

Why this answer

Database methods returning partial success provide a list of Database.SaveResult objects that contain error details.

313
MCQhard

A developer needs to access a specific HTML element in a Lightning Web Component template imperatively. Which method should be called?

A.window.findElement()
B.this.template.querySelector()
C.this.findElement()
D.document.querySelector()
AnswerB

Shadow DOM encapsulation in Lightning Web Components restricts direct global DOM access, requiring scoped traversal to locate elements. The `this.template.querySelector()` method satisfies the requirement to access a specific HTML element imperatively from within the component's JavaScript controller by searching solely within the component's own template template-bound boundary. This approach ensures compliance with Lightning security and encapsulation paradigms, allowing developers to query and manipulate targeted DOM nodes reliably without breaking component isolation rules.

Why this answer

In Lightning Web Components, to access an element in the template imperatively, you must use this.template.querySelector() with a CSS selector. This method scopes the query to the component's template, ensuring encapsulation and preventing access to elements outside the component. It returns the first matching element.

Exam trap

SALESFORCE-PD1 often tests the correct method for DOM access in LWC, and candidates may mistakenly use document.querySelector() due to familiarity with standard web development, ignoring LWC's encapsulation.

How to eliminate wrong answers

Option A is wrong because window.findElement() is not a standard method and does not exist in the DOM API. Option C is wrong because this.findElement() is not a method provided by the LightningElement base class. Option D is wrong because document.querySelector() queries the entire document, which breaks component encapsulation and may return elements outside the component, leading to unpredictable behavior and potential security issues.

314
MCQmedium

What is the primary purpose of the 'System.debug()' statement?

A.To display an error to the end user
B.To stop the execution of the code
C.To log an audit trail of configuration changes
D.To write information to the debug log
AnswerD

Executing a `System.debug()` statement directly serialises messages into the execution context, which subsequently generates a log entry within the Salesforce debug log. This mechanism satisfies the stem's requirement to record runtime information, enabling developers to monitor variable states and control flow during Apex execution without altering the transactional database.

Why this answer

System.debug() writes information to the Salesforce debug log, which developers use to trace execution, inspect variable values, and diagnose issues during development and troubleshooting. The output appears in the Developer Console, the debug log viewer, or via the Streaming API, and is governed by the log level set in the trace flag. It does not surface anything to end users or alter execution flow.

Exam trap

Salesforce-PD1 often tests the purpose of System.debug() — the trap is confusing it with user-facing error display (ApexPages.addMessage) or execution control (throw/breakpoint), when it is purely a server-side logging statement.

How to eliminate wrong answers

Option A is wrong because System.debug() writes to the debug log, not to the user interface — to show an error to a user you would use ApexPages.addMessage(), a toast, or a custom exception surfaced in the UI. Option B is wrong because System.debug() does not stop execution; to halt code you would throw an exception or use a breakpoint in the Apex debugger. Option C is wrong because audit trails of configuration changes are captured by Setup Audit Trail and Field History Tracking, not by System.debug(), which is a developer-time logging statement.

315
MCQmedium

A developer is writing a Visualforce page that uses a custom controller. The page needs to execute an action method as soon as the page loads, without requiring user interaction. Which attribute on <apex:page> should be used?

A.initMethod="{!init}"
B.action="{!init}"
C.onLoad="{!init}"
D.loadAction="{!init}"
AnswerB

The `action` attribute on the `<apex:page>` component evaluates a controller method when the page is requested, fulfilling the requirement to execute logic immediately upon loading without user intervention. By binding this attribute to a controller method expression such as `{!init}`, the Salesforce platform automatically invokes the specified server-side code during the initial HTTP request lifecycle. This mechanism ensures the necessary initialisation occurs before the markup is rendered to the client browser.

Why this answer

The `action` attribute on `<apex:page>` specifies a controller method that is executed when the page loads, before rendering, without user interaction. It is the standard Visualforce mechanism for initialization logic, such as loading data or setting up state. The correct syntax is `action="{!init}"`, where `init` is a public method in the custom controller.

Exam trap

Salesforce-PD1 often tests the confusion between `action` and non-existent attributes like `initMethod` or `onLoad` — candidates pick the most descriptive-sounding name instead of the actual Visualforce attribute.

How to eliminate wrong answers

Option A is wrong because `initMethod` is not a valid attribute on `<apex:page>`; it does not exist in the Visualforce component reference. Option C is wrong because `onLoad` is not a valid `<apex:page>` attribute — `onload` exists as a JavaScript event attribute in some contexts, but not as a controller action binding on `<apex:page>`. Option D is wrong because `loadAction` is not a recognized Visualforce attribute; it is a fabricated name that resembles `action` but has no effect.

316
MCQeasy

Which tool is best for automating a process that requires UI interaction, such as a wizard screen?

A.Future Method
B.Flow Builder
C.Batch Apex
D.Apex Trigger
AnswerB

Screen Flows within Flow Builder provide a reactive user interface via configurable wizard-like screens, successfully satisfying the stem's requirement for direct UI interaction. Unlike backend automation tools that execute entirely without user touchpoints, Flow Builder supports the rendering of step-by-step visual components, input fields, and navigational buttons directly within Lightning pages or experiences, allowing administrators to guide users through complex data-collection processes sequentially.

Why this answer

Flow Builder is the only declarative tool among the options that can present screen elements (wizard-style UI) to users, collecting input across multiple steps and then performing logic or DML. Screen Flows are specifically designed for guided UI interaction, making Flow Builder the correct choice for automating a process that requires a wizard screen.

Exam trap

The trap is conflating 'automation' with 'UI automation'—candidates may pick Batch Apex or Triggers because they automate processes, but only Flow Builder can render interactive screens.

How to eliminate wrong answers

Option A is wrong because a Future method is an asynchronous Apex construct that runs in the background with no UI—it cannot render screens or collect user input. Option C is wrong because Batch Apex processes large data volumes asynchronously in chunks, with no user-facing interface. Option D is wrong because an Apex Trigger fires automatically on DML events (insert/update/delete) and cannot present UI to a user.

317
MCQhard

A developer writes an Apex method that executes a SOQL query using user-supplied search parameters. How can the developer protect against SOQL injection vulnerabilities?

A.Execute the query using Database.queryWithBinds() with a restricted access modifier.
B.Use bind variables in the SOQL query instead of string concatenation.
C.Use String.escapeSingleQuotes() on all user inputs before concatenating into the query string.
D.Enclose all dynamic parameters in single quotes within the dynamic SOQL query string.
AnswerB

Using bind variables satisfies the constraint of executing a SOQL query using user-supplied search parameters securely. When developers integrate dynamic user input via string concatenation, malicious actors can manipulate the query logic. By substituting string concatenation with bind variables (using the colon syntax, such as `:userInput`), the Salesforce platform treats the input strictly as a literal value rather than executable query syntax. This completely neutralises SOQL injection attempts, ensuring the query structure remains unaltered regardless of the input's content.

Why this answer

Using bind variables in SOQL queries automatically sanitizes the input and prevents SOQL injection, unlike string concatenation.

318
MCQhard

A developer is creating a Lightning Web Component that needs to conditionally render a section based on a boolean property. The property is initially false and is set to true after data is loaded from an Apex method. Which approach should the developer use to ensure the section renders only when the property is true?

A.Use the if:true directive on the section element.
B.Use a JavaScript querySelector to add or remove the section element from the DOM.
C.Use a CSS class with display: none and toggle it based on the property.
D.Use the rendered attribute on the section element.
AnswerA

The if:true directive conditionally renders the element and its children only when the bound expression evaluates to true. In this scenario, when the boolean property becomes true after data load, the section will render. This is the standard declarative way to conditionally render content in Lightning Web Components.

Why this answer

Conditional rendering in Lightning Web Components is done using if:true or if:false directives. These directives add or remove elements from the DOM based on the truthiness of the bound expression. When the boolean property changes to true, the section is rendered.

This approach is efficient and aligns with the framework's reactive model.

Exam trap

The trap here is confusing Aura's rendered attribute with LWC's if:true directive, or resorting to CSS hiding, which does not actually remove elements from the DOM.

319
MCQmedium

A developer needs to write a unit test for a Queueable Apex class. How should the developer verify that the Queueable job executed successfully?

A.Use System.assertAsync() to poll the job status table.
B.Enclose the execution within Test.startTest() and Test.stopTest(), then query for the resulting record changes.
C.Query the AsyncApexJob table without Test.stopTest().
D.Call the queueable execute method directly in a try-catch block.
AnswerB

Test.stopTest() forces all asynchronous jobs queued since Test.startTest() to run synchronously before execution resumes. This satisfies the requirement to verify the Queueable job's outcome, since querying afterwards reliably reflects the record changes the job performed. Without this boundary, the job would remain pending and assertions would fail.

Why this answer

Queueable jobs executed inside Test.startTest() and Test.stopTest() run synchronously upon reaching stopTest(), allowing assertions to be checked immediately after.

320
Multi-Selectmedium

Which THREE of the following are true about Apex test data setup?

Select 3 answers
A.@TestSetup methods run once per test class
B.Test data is automatically committed to the database
C.Tests can use existing data from the org if 'SeeAllData=true' is set
D.Test data must be inserted into the database to be queryable
E.Test classes can only use data created within the same method
AnswersA, C, D

Annotating a method with `@TestSetup` ensures that the enclosed data setup logic executes precisely once for the entire test class context, satisfying the requirement to efficiently create common records shared across multiple test methods. This mechanism significantly reduces execution time and prevents governor limit consumption by avoiding repetitive data insertion routines within individual test methods, rolling back any DML changes automatically after each test method completes to maintain data isolation.

Why this answer

Data setup should use @TestSetup where possible, avoid using actual production data, and be isolated from the database.

321
MCQmedium

A developer needs to execute a dynamic SOQL query where the object name and fields are determined at runtime. Which method should be used?

A.Record.query()
B.System.query()
C.SOQL.query()
D.Database.query()
AnswerD

`Database.query()` accepts a string variable as its sole argument, allowing developers to construct SOQL statements dynamically by concatenating object names and field identifiers at runtime. This capability directly satisfies the requirement to handle variable schema elements that are unknown during compilation. Unlike static SOQL, which requires hard-coded object and field references, this method processes the query string during execution, providing the necessary flexibility to adapt to changing runtime parameters while maintaining full integration with the Salesforce database engine.

Why this answer

Database.query() allows execution of dynamically constructed SOQL query strings.

322
MCQmedium

A developer is working with a Lightning Web Component that uses the @wire decorator to provision data from an Apex method. The Apex method depends on a property that changes dynamically. How should the property be prefixed to signal reactivity to the wire service?

A.Enclose the property name in curly braces ({})
B.Prefix the property name with a dollar sign ($)
C.Prefix the property name with an ampersand (&)
D.Prefix the property name with an underscore (_)
AnswerB

The dollar-sign prefix marks a property as reactive, so the wire service re-invokes the Apex method whenever that property's value changes. Without it, the wire adapter provisions data only once, ignoring the dynamic dependency described in the stem.

Why this answer

In Lightning Web Components, the @wire decorator uses a reactive variable syntax where a property prefixed with a dollar sign ($) is treated as a dynamic parameter. When that property changes, the wire service automatically re-invokes the Apex method with the new value. This is the documented LWC reactive wire pattern, e.g., @wire(getContact, { contactId: '$recordId' }).

Exam trap

Salesforce-PD1 often tests the distinction between Aura's {!v.property} expression syntax and LWC's '$property' reactive wire syntax, causing candidates who recently studied Aura to select the curly-brace option.

How to eliminate wrong answers

Option A is wrong because curly braces ({}) are the Aura component expression syntax (e.g., {!v.recordId}), not the LWC wire reactivity marker — LWC templates use {property} for rendering, but the wire adapter specifically requires the $ prefix. Option C is wrong because the ampersand (&) has no special meaning in LWC wire parameter binding; it is not a reactivity sigil in any Salesforce UI framework. Option D is wrong because an underscore prefix is a JavaScript naming convention for private/internal members and carries no semantic meaning to the wire service.

323
Multi-Selectmedium

A developer is writing an Apex trigger and needs to ensure proper bulkification. Which TWO practices should the developer follow to avoid governor limits? (Choose two.)

Select 2 answers
A.Use single record DML statements inside a standard for-loop.
B.Hardcode record IDs to query specific test records.
C.Perform SOQL queries and DML operations outside of loops.
D.Annotate the trigger with @future to ensure asynchronous bulk processing.
E.Use Trigger context variables such as Trigger.new to process collections of records.
AnswersC, E

Executing SOQL queries or DML operations inside loops directly causes a failure to satisfy the critical bulkification requirement, as Salesforce enforces strict governor limits of 100 SOQL queries and 150 DML statements per transaction. By relocating these database interactions outside of code loops and processing records in collections, the developer aggregates the operations into single bulk requests. This architectural pattern drastically reduces the total number of transaction context executions, ensuring the Apex trigger successfully scales to handle multiple records simultaneously without hitting runtime limits.

Why this answer

Bulkification requires processing data in collections (lists/sets) and placing all DML and SOQL operations outside of loops.

324
MCQeasy

Which primitive data type in Apex can represent a specific point in time, including both date and time values?

A.Date
B.Time
C.Datetime
D.Timestamp
AnswerC

The Datetime data type serves as the standard Apex primitive for capturing both calendar dates and clock times within a single variable. By storing values as Coordinated Universal Time (UTC) milliseconds, it satisfies the stem’s requirement for a specific point in time. Unlike the Date type, which lacks temporal precision, Datetime provides the necessary granularity to track events or timestamps accurately, ensuring developers can perform precise arithmetic and comparisons across different time zones when integrating with systems like Microsoft Entra ID.

Why this answer

The Datetime data type represents both a date and a time in Apex.

325
MCQhard

A developer is implementing a custom pagination mechanism in a Lightning Web Component. The component uses an Apex controller method that returns a list of records. Which technique prevents excessive heap size and improves performance when dealing with large datasets?

A.Fetch all records in a single transaction and slice the array in JavaScript.
B.Store the entire dataset in browser local storage for client-side manipulation.
C.Use the @wire decorator with an unbounded query and enable auto-caching.
D.Use server-side pagination passing page offset and limit parameters to the Apex controller.
AnswerD

Passing page offset and limit parameters directly to the Apex controller ensures that only the specific subset of records required for the current view is queried and transferred, satisfying the requirement to prevent excessive heap size and improve performance when dealing with large datasets. By leveraging SOQL `LIMIT` and `OFFSET` clauses, the server-side code avoids loading thousands of unnecessary records into memory, thereby respecting Salesforce governor limits and drastically reducing payload size over the network.

Why this answer

Implementing server-side pagination with OFFSET and LIMIT or using standard database query locators in Apex is best practice.

326
MCQhard

A developer needs to iterate over a map of Account IDs to Account sObjects and perform processing on each value. Which loop construct is valid Apex?

A.for(KeyValue kv : myMap.entrySet()) { ... }
B.for(Account acc : myMap) { ... }
C.for(Account acc : myMap.values()) { ... }
D.for(Id id : myMap.iterator()) { ... }
AnswerC

Apex maps expose a values() method returning a collection of the map's values, which is iterable with the enhanced for-loop. Since the map is keyed by ID with Account sObjects as values, iterating values() yields each Account directly, matching the required processing.

Why this answer

Iterating over map values is done using map.values() in a for-loop: for(Account acc : myMap.values()).

327
Multi-Selecthard

Which THREE practices are considered security best practices when developing custom Visualforce pages to prevent Cross-Site Scripting (XSS)? Choose 3 answers.

Select 3 answers
A.Use standard Visualforce components like <apex:outputText> which automatically HTML-escape output by default.
B.Disable sharing on all controller classes.
C.Set escape="false" on all output components to ensure proper rendering.
D.Use String.escapeJavaScript() when rendering user input inside JavaScript contexts.
E.Encode untrusted user input using JSENCODE or HTMLENCODE helper functions.
AnswersA, D, E

Standard Visualforce components such as `<apex:outputText>` provide an automatic HTML-escaping mechanism that neutralises malicious scripts before rendering data in the browser. This directly satisfies the requirement to prevent Cross-Site Scripting (XSS) vulnerabilities by ensuring that user-supplied input or dynamic field values containing executable JavaScript cannot be interpreted as code by the Document Object Model. By default, these built-in components encode characters like `<` and `>` into their safe entity equivalents, mitigating injection risks without requiring manual developer intervention.

Why this answer

Preventing XSS in Visualforce involves escaping output, using standard components which escape by default, and encoding untrusted data.

328
MCQeasy

A developer is writing an Apex method and needs to store a collection of unique email addresses while maintaining fast lookup times. Which collection should the developer choose?

A.List<String>
B.Queue<String>
C.Map<String, Integer>
D.Set<String>
AnswerD

A `Set<String>` automatically enforces uniqueness by preventing duplicate entries, which directly satisfies the requirement for storing unique email addresses. Internally, Apex sets utilise a hash table implementation to ensure that lookups, additions, and removals occur in constant time, $O(1)$, on average. This high-performance mechanism provides the fast lookup times necessary for efficient data retrieval within an Apex method, making it the optimal choice for managing collections where uniqueness and rapid access are the primary technical constraints.

Why this answer

Sets in Apex store unique elements and provide efficient membership testing methods like contains().

329
MCQmedium

A developer needs to query all Contact records, including those that have been deleted from the database via the Recycle Bin. Which SOQL clause must be added?

A.INCLUDING DELETED
B.FOR VIEW
C.FOR REFERENCE
D.ALL ROWS
AnswerD

Including the ALL ROWS clause in a SOQL query explicitly instructs the database engine to bypass the default filter that excludes soft-deleted records. By satisfying the requirement to retrieve data currently residing in the Recycle Bin, this keyword extends the query scope beyond active records. This mechanism is essential for auditing or recovering information that has not yet been permanently purged from the system, ensuring the developer can access the complete dataset regardless of its current lifecycle state within the platform.

Why this answer

ALL ROWS must be appended to a SOQL query to include records in the Recycle Bin (deleted records) and archived tasks/events.

330
Multi-Selectmedium

When comparing Flow Builder decision points and Apex trigger logic, which THREE statements are valid design considerations? (Choose THREE.)

Select 3 answers
A.Apex triggers are executed after all Flow Builder automations have completed.
B.Apex triggers provide superior control for complex exception handling and multi-object transaction orchestration.
C.Flow Builder allows administrators to configure logic visually, reducing maintenance overhead for non-developers.
D.Flow Builder cannot invoke Apex actions.
E.Record-Triggered Flows can execute either before or after the record is saved to the database.
AnswersB, C, E

Apex triggers enable developers to implement granular try-catch blocks and custom rollback logic, which are essential for managing complex exception handling across multi-object transactions. Unlike Flow Builder, which operates within a more constrained declarative framework, Apex provides programmatic access to the full transaction lifecycle. This capability satisfies the design requirement for robust orchestration, allowing developers to maintain data integrity and precise control when performing cross-object operations that necessitate sophisticated error management beyond standard declarative capabilities.

Why this answer

Flows are declarative, easier to maintain, and execute within governor limits, whereas Apex handles complex integrations and high-volume data manipulations.

331
MCQmedium

A developer needs to query all Contact records, including those that have been moved to the Recycle Bin. Which SOQL keyword should be used?

A.ALL ROWS
B.WITH RECYCLE_BIN
C.SYSTEM MODE
D.INCLUDE DELETED
AnswerA

The `ALL ROWS` keyword explicitly instructs the Salesforce database engine to bypass the default filter that excludes soft-deleted records. By including this clause in a SOQL query, a developer can retrieve Contact records currently residing in the Recycle Bin alongside active data. This mechanism directly satisfies the requirement to query records moved to the Recycle Bin, as standard queries ignore these entities by design to optimise performance and maintain data integrity within the active operational set.

Why this answer

The ALL ROWS clause in SOQL allows queries to return deleted records (from the Recycle Bin) as well as archived tasks and events.

332
MCQeasy

A developer needs to ensure that a Lightning Web Component can be placed on a Record Page for an Account in the Lightning App Builder. What must be configured in the component's metadata configuration file?

A.<target>lightning__HomePage</target>
B.<target>lightning__RecordPage</target>
C.<target>lightning__Tab</target>
D.<target>lightningCommunity__Default</target>
AnswerB

Including the `lightning__RecordPage` target within the `targets` array of the component’s metadata file explicitly enables the component to be surfaced within the Lightning App Builder for record-specific pages. This configuration satisfies the requirement to place the component on an Account Record Page by registering the component’s availability for the record page context. Without this specific target declaration, the Lightning App Builder will not display the component in the custom components list, thereby preventing its deployment to the desired user interface.

Why this answer

The target configuration must include lightning__RecordPage and specify the appropriate object support.

333
MCQmedium

A developer implemented a Queueable Apex class that performs heavy processing. During testing, the developer wants to verify whether the asynchronous job has finished executing before running dependent unit test assertions. What should the developer use?

A.Test.startTest() and Test.stopTest() block around the enqueueJob call
B.AsyncApexJob query inside a loop with Thread.sleep()
C.A custom countdown latch pattern using platform cache
D.System.assertAsyncExecution() method
AnswerA

Wrapping the `enqueueJob` call within a `Test.startTest()` and `Test.stopTest()` block forces the asynchronous process to execute synchronously within the test context. Once `Test.stopTest()` is invoked, the platform processes all queued jobs, ensuring they complete before the subsequent lines of code execute. This mechanism satisfies the requirement to verify job completion before running dependent assertions, as it guarantees that the heavy processing finishes and all resulting database changes are committed before the test continues to evaluate the final state.

Why this answer

Developers use Test.startTest() and Test.stopTest() in unit tests to force all asynchronous jobs enqueued within the block to execute synchronously before proceeding.

334
MCQhard

When using the Salesforce CLI to deploy, what is the 'check-only' flag used for?

A.To validate the metadata without saving it to the org.
B.To force the deployment despite test failures.
C.To skip the compilation check.
D.To run only the tests.
AnswerA

Validating metadata via the `--check-only` flag triggers a server-side deployment process that executes all Apex tests and component integrity checks without committing changes to the target org. This mechanism satisfies the requirement to verify deployment readiness in a sandbox or production environment while ensuring no persistent modifications occur. By performing this dry run, developers can identify potential integration failures or configuration conflicts before finalising the release, thereby maintaining the stability of the environment during the continuous integration lifecycle.

Why this answer

It validates the deployment without committing changes to the target org.

335
MCQhard

A developer has an Aura component that needs to communicate with an unrelated Lightning Web Component located on the same Lightning page. Which feature should the developer implement?

A.Lightning Message Service (LMS)
B.Aura Component Events (app events)
C.A shared JavaScript closure via window globals
D.Direct DOM traversal using document.querySelector()
AnswerA

Lightning Message Service provides a standardised publish-subscribe mechanism that enables communication across the DOM, effectively bridging the gap between Aura components and Lightning Web Components. By utilising a MessageChannel, developers can facilitate decoupled interaction between components that do not share a common parent. This approach satisfies the constraint of the components being unrelated, as it bypasses the limitations of traditional parent-child event propagation, ensuring seamless data exchange regardless of the component hierarchy or the specific framework used within the Lightning page.

Why this answer

The Lightning Message Service (LMS) allows communication between Visualforce pages, Aura components, and Lightning Web Components across the DOM.

336
MCQmedium

A developer is building a Lightning Web Component that displays a list of contacts for a selected account. The component must call an Apex method that returns contacts, and the developer wants to handle the result using a Promise chain. Which Apex method annotation is required to expose the method to the Lightning Web Component?

A.@HttpGet
B.@AuraEnabled(cacheable=true)
C.@RemoteAction
D.@InvocableMethod
AnswerB

This annotation makes the Apex method available to Lightning Web Components via the wire service and imperative calls. It also enables client-side caching, which improves performance. Without it, the method cannot be called from the component, so it is the correct choice for exposing server-side logic to LWC.

Why this answer

Lightning Web Components communicate with Apex via methods annotated with @AuraEnabled. The annotation can include cacheable=true to enable client-side caching, which is beneficial for read-only operations. Without @AuraEnabled, the Apex method is not exposed to the component, and the import statement would fail.

Therefore, the correct annotation is @AuraEnabled(cacheable=true).

Exam trap

The trap here is confusing @AuraEnabled with other Apex annotations like @RemoteAction or @InvocableMethod, which serve different integration purposes and are not used for direct LWC-to-Apex calls.

337
MCQmedium

A developer is building a Lightning Web Component that includes user input fields. To adhere to best practices for accessibility and SLDS form styling, how should form inputs be structured?

A.Use standard HTML inputs without associated label elements.
B.Use <table> tags for layout alignment of form fields.
C.Use SLDS form element containers with corresponding <lightning-input> or HTML input elements paired with explicit labels.
D.Apply inline CSS display:flex directly to raw text areas.
AnswerC

Pairing each input with an explicit label satisfies the accessibility requirement, since SLDS form element containers expect a label element bound to the input's id. Using `<lightning-input>` supplies that association automatically, while raw HTML inputs need a matching `for` attribute, meeting the stem's SLDS styling and accessibility constraints.

Why this answer

SLDS provides form element containers (slds-form-element, slds-form-element__label, slds-form-element__control) that pair labels with inputs for correct spacing, alignment, and screen-reader association. Using lightning-input (which renders SLDS-compliant markup with built-in label support) or native HTML inputs wrapped in these SLDS containers with explicit <label for> associations satisfies both accessibility and styling best practices.

Exam trap

The trap is treating form layout as a pure visual concern — candidates pick table-based or inline-CSS options because they 'look' like they align fields, ignoring that SLDS containers and explicit label association are required for both accessibility compliance and consistent Lightning styling.

How to eliminate wrong answers

Option A is wrong because inputs without associated label elements fail WCAG accessibility requirements — screen readers cannot announce the field's purpose, and SLDS styling for labels is bypassed. Option B is wrong because using <table> tags for layout is a deprecated, non-responsive technique that breaks SLDS grid conventions and harms accessibility since tables imply tabular data relationships to assistive technology. Option D is wrong because applying inline display:flex to raw text areas bypasses SLDS design tokens, breaks consistent theming, and does not address label association or accessibility at all.

338
MCQmedium

A developer needs to run a batch job that queries records and updates them. What is the default batch size if no optional batch size parameter is specified in Database.executeBatch()?

A.200
B.50
C.2000
D.500
AnswerA

Database.executeBatch() defaults to 200 records per batch when the optional scope parameter is omitted, satisfying the stem's condition of no specified batch size. This default governs how many records each batch chunk processes before the job commits, directly answering the question's requirement for the standard behaviour.

Why this answer

The default batch size for Database.executeBatch() is 200 records if not specified.

339
MCQeasy

A developer is building a Lightning Web Component and needs to execute code as soon as the component is inserted into the DOM. Which lifecycle hook should be used?

A.renderedCallback
B.constructor
C.connectedCallback
D.disconnectedCallback
AnswerC

The `connectedCallback` lifecycle hook executes automatically when a component is inserted into the DOM, satisfying the requirement to trigger code immediately upon mounting. Unlike the `constructor` which runs before the component is connected, this hook provides access to the element's properties and the DOM environment. It serves as the standard entry point for initialising data or performing setup tasks, ensuring that the component is fully integrated into the page structure before the logic begins to execute.

Why this answer

The connectedCallback lifecycle hook is called when a component is inserted into the DOM. It is the appropriate place to execute initialization code that requires the component to be in the document, such as accessing the DOM or making imperative Apex calls.

Exam trap

Salesforce PD1 often tests the distinction between connectedCallback and renderedCallback; candidates may confuse the two, thinking renderedCallback is for initial insertion, but it actually runs after every render.

How to eliminate wrong answers

Option A is wrong because renderedCallback is called after the component is rendered, which occurs after connectedCallback; it is used for post-render logic, not initial insertion. Option B is wrong because the constructor is called before the component is inserted into the DOM; it is used for initializing state but cannot access the DOM or perform certain operations. Option D is wrong because disconnectedCallback is called when the component is removed from the DOM, not when inserted.

340
MCQhard

A developer implements a Queueable class that makes callouts and needs to test it using Test.startTest() and Test.stopTest(). When does the asynchronous queueable job execute during a unit test?

A.At the end of the test method automatically without stopTest.
B.Immediately when enqueued.
C.Only when explicitly mocked via HttpCalloutMock.
D.When Test.stopTest() is executed.
AnswerD

Executing `Test.stopTest()` forces the asynchronous queueable job to process immediately within the unit test context. This mechanism satisfies the constraint of testing callouts, which are otherwise prohibited in synchronous Apex code. By wrapping the job execution between `Test.startTest()` and `Test.stopTest()`, the developer ensures the platform processes the queued task before the test assertions are evaluated. This approach allows for the verification of side effects resulting from the callout, providing a reliable method to validate asynchronous logic without relying on external system timing.

Why this answer

Asynchronous code executed inside Test.startTest() and Test.stopTest() runs synchronously when Test.stopTest() is called.

341
MCQhard

A developer creates a Trigger on the Account object that performs a SOQL query inside a for loop. While testing with bulk data operations, the developer encounters a governor limit exception. Which limit is most likely exceeded?

A.Maximum CPU time on a Salesforce server (10,000 milliseconds)
B.Total number of SOQL queries issued (100)
C.Total heap size allocated (6 MB)
D.Total number of DML statements issued (150)
AnswerB

A SOQL query inside a for loop executes once per record, so bulk operations quickly exhaust the 100 synchronous query limit. Salesforce counts each loop iteration as a separate query against the governor limit, unlike a single query outside the loop. This directly satisfies the stem's bulk-data constraint.

Why this answer

Executing SOQL queries inside a loop without bulkification easily causes the total number of SOQL queries issued per transaction (100) to be exceeded.

342
Multi-Selectmedium

A developer is creating an Aura component that interacts with Salesforce data. Which TWO tags or features are valid in the Aura framework? (Choose TWO)

Select 2 answers
A.<aura:iteration items="{!v.items}" var="item">
B.<template for:each={items} for:item="item">
C.<aura:attribute name="myAttr" type="String" />
D.<lwc:databind property="{!v.val}" />
E.import { LightningElement } from 'lwc';
AnswersA, C

The `<aura:iteration>` tag acts as the primary mechanism for rendering collections within the Aura framework, satisfying the requirement to interact with Salesforce data by dynamically iterating over an array of records. By binding the `items` attribute to a controller-provided list, developers can efficiently generate repetitive UI elements based on server-side data. This tag is essential for data-driven components, as it handles the transformation of complex object collections into individual component instances without requiring manual DOM manipulation or external libraries.

Why this answer

Option A is correct because <aura:iteration> is a core Aura framework tag used to iterate over a collection such as v.items, rendering the body once per element with the specified var attribute. Option C is correct because <aura:attribute> is the standard Aura tag for declaring a component attribute, with name and type (e.g., String) being valid attributes. Option B is not valid Aura syntax; for:each and for:item are Lightning Web Components template directives, not Aura tags.

Option D is not valid; lwc:databind is not an Aura or LWC feature, and Aura uses {!v.val} expressions without such a tag. Option E is not valid in an Aura component because import { LightningElement } from 'lwc' is the LWC base class import, used in JavaScript files of Lightning Web Components, not Aura.

Exam trap

The trap here is mixing Aura and LWC syntax in the same question — candidates who have studied both frameworks may incorrectly select LWC constructs (for:each, LightningElement import) as valid Aura features.

343
Multi-Selecthard

Which THREE factors influence deployment success?

Select 3 answers
A.The number of users.
B.Profile/Permission Set permissions.
C.Dependent components.
D.Test coverage.
E.The color of the UI.
AnswersB, C, D

Profile and Permission Set settings must be explicitly included in the deployment package to ensure that users retain necessary access rights within the target environment. When migrating metadata, the absence of these security definitions causes a mismatch between the component availability and user visibility, directly satisfying the requirement to maintain functional parity across environments. Unlike identity management systems such as Microsoft Entra ID, Salesforce metadata deployments require manual inclusion of these permission objects to prevent post-deployment access failures for end users.

Why this answer

Tests, dependencies, and profile permissions are critical.

344
Multi-Selecthard

A developer is designing an asynchronous architecture using Batch Apex. Which THREE considerations must be kept in mind regarding Batch Apex behavior? (Choose THREE.)

Select 3 answers
A.The maximum batch size query locator limit is 200 records maximum.
B.Up to 5 batch jobs can be in execution concurrently for a single organization.
C.Batch Apex automatically executes synchronously if triggered from a Visualforce controller.
D.Batch jobs placed in the queue when the active limit is reached enter the Flex Queue in Holding status.
E.Implementing Database.Stateful ensures member variables retain their values across all transaction chunks.
AnswersB, D, E

Salesforce enforces a strict concurrency limit on asynchronous processing to maintain platform stability and resource availability across multi-tenant environments. Specifically, the organisation-wide governor limit restricts the number of Batch Apex jobs that can run simultaneously to five. This constraint directly addresses the requirement for managing system load when designing asynchronous architectures. Developers must account for this threshold to ensure that queued processes do not exceed the permitted execution capacity, which would otherwise result in jobs being held in a holding status until resources become available.

Why this answer

Batch apex jobs are queued in the Flex queue, can execute up to 5 concurrent jobs, and can maintain state using Stateful.

345
Multi-Selectmedium

Which TWO of the following are valid deployment tools?

Select 2 answers
A.Salesforce CLI.
B.Change Sets.
C.System Log.
D.Developer Console Debugger.
E.Apex Test Runner.
AnswersA, B

Salesforce CLI functions as a command-line interface that facilitates the movement of metadata between local development environments and Salesforce organisations. By utilising the Salesforce Extensions for VS Code, developers can package and deploy components directly to sandboxes or production environments. This tool satisfies the requirement for a valid deployment mechanism by providing a robust, scriptable interface for metadata API operations, ensuring that code and configuration changes are synchronised efficiently across the development lifecycle without relying on manual browser-based uploads.

Why this answer

Salesforce CLI (A) is a valid deployment tool because it provides command-line commands such as 'sf project deploy start' (formerly 'sfdx force:source:deploy') that push metadata and source from a local project to an org, supporting both source and metadata formats. Change Sets (B) are a valid deployment tool because they let you bundle metadata components in a source org and deploy them to a target org through the Setup UI, typically between related orgs such as sandbox to production. The other options are not deployment tools: System Log (C) is a monitoring/diagnostic feature for viewing execution logs, Developer Console Debugger (D) is used to inspect and troubleshoot Apex and other code at runtime, and Apex Test Runner (E) is for executing Apex tests to validate code, not for moving metadata between orgs.

Exam trap

SALESFORCE-PD1 often tests tool categorization, and candidates confuse monitoring/debugging tools like System Log or Developer Console with deployment tools.

Page 4

Page 5 of 5

All pages