Courseiva

CCNA User Interface Questions

75 of 91 questions · Page 1/2 · User Interface · Answers revealed

1
MCQeasy

A developer is writing a Visualforce page and wants to include standard Salesforce styling and icons. What tag should be added to the top of the Visualforce page?

A.<apex:lightningStyleguide />
B.<apex:stylesheet value="{!$Resource.SLDS}" />
C.<apex:includeLightning />
D.<apex:slds />
AnswerD

`<apex:slds />` is the correct component because it explicitly satisfies the requirement to include standard Salesforce styling and modern icons within a Visualforce page. By adding this single tag to the top of the markup, the page automatically loads the Salesforce Lightning Design System (SLDS) stylesheet and asset library without requiring manual static resource uploads or custom CSS configuration, providing native access to Lightning Design System styling tokens and SVG icons.

Why this answer

<apex:slds /> includes the Salesforce Lightning Design System styles and assets in a Visualforce page.

2
MCQeasy

Which lifecycle hook in a Lightning Web Component is called after every render of the component?

A.constructor
B.connectedCallback
C.errorCallback
D.renderedCallback
AnswerD

The `renderedCallback()` lifecycle hook executes every time a component finishes rendering its HTML template, satisfying the requirement to run logic after *every* render cycle. Unlike `connectedCallback()`, which fires only once when the component is inserted into the DOM, `renderedCallback()` is called after initial rendering and subsequent re-renders triggered by reactive property changes. This makes it suitable for integrating third-party JavaScript libraries or performing manual DOM manipulations that must remain synchronised with the latest component state.

Why this answer

The renderedCallback hook is invoked after every render of the component, including the initial render and subsequent re-renders. It is used for logic that needs to run after the DOM is updated, such as manipulating the DOM or accessing rendered elements.

Exam trap

Salesforce PD1 often tests the frequency of renderedCallback versus connectedCallback; candidates may incorrectly think renderedCallback runs only once, but it runs after every render.

How to eliminate wrong answers

Option A is wrong because the constructor is called once when the component is created, before rendering, and is not called again on re-renders. Option B is wrong because connectedCallback is called only when the component is inserted into the DOM, not after every render. Option C is wrong because errorCallback is called when a descendant component throws an error, not after render.

3
MCQeasy

A developer is building a Lightning Web Component and wants to define a property that can be set by a parent component. Which decorator is required?

A.@track
B.@api
C.@auraEnabled
D.@wire
AnswerB

The `@api` decorator satisfies the requirement to define a public property that a parent component can set, marking the field as reactive and part of the component's public API. In Salesforce Lightning Web Components, fields are private by default; applying `@api` exposes the property so that parent components can pass data down into the child's template using HTML attributes or JavaScript properties.

Why this answer

The @api decorator in Lightning Web Components marks a property or method as public, making it accessible to parent components. It is the required decorator for any property that a parent needs to set, and it also makes the property reactive. Without @api, the property is private and cannot be set from outside the component.

Exam trap

Salesforce PD1 often tests the confusion between @api and @track, where candidates incorrectly choose @track for parent-to-child property passing, not realizing @track is for private reactivity and @api is for public exposure.

How to eliminate wrong answers

Option A is wrong because @track is used to make a private property reactive for changes to nested object properties or array elements — it does not expose the property to parent components. Option C is wrong because @auraEnabled is an Aura-specific decorator used to expose Aura controller methods to Lightning components, not an LWC decorator for public properties. Option D is wrong because @wire is used to provision data from a Salesforce wire adapter (e.g., getRecord) and does not define a public property for parent-to-child communication.

4
MCQeasy

A developer is writing a Visualforce page and wants to display messages generated by controllers or validation rules. Which component should be used?

A.<apex:pageMessages />
B.<apex:errorMessages />
C.<apex:outputPanel type="messages" />
D.<apex:messageLog />
AnswerA

The `<apex:pageMessages />` component directly satisfies the requirement to display all messages generated by controllers or validation rules simultaneously. It automatically aggregates and renders every message added to the Apex `ApexPages` context, including standard database save exceptions, custom controller `ApexPages.Message` instances, and field-level validation errors triggered during DML operations. By rendering this unified collection in a single block, it provides the precise mechanism needed for comprehensive error handling on a Visualforce page without requiring manual iteration through individual message lists.

Why this answer

<apex:pageMessages /> displays all messages queued on the page for the current request.

5
Multi-Selecteasy

Which TWO statements are true regarding the differences between Aura components and Lightning Web Components (LWC)? (Choose TWO)

Select 2 answers
A.LWC components cannot contain HTML markup tags.
B.Aura components are required for all modern mobile app development while LWC is restricted to desktop only.
C.Lightning Web Components take advantage of native web standards built directly into modern browsers.
D.Aura components use standard Shadow DOM encapsulation without component-specific framework abstractions.
E.Lightning Web Components execute with better performance because they run on native browser engine features.
AnswersC, E

Lightning Web Components leverage modern web standards by running on the core ECMAScript, custom elements, and shadow DOM features supported natively by browsers, eliminating the heavy proprietary abstraction layer that Aura requires. This architectural difference directly satisfies the stem's requirement to identify structural contrasts between the two frameworks, as Aura relies on a proprietary component model and framework-specific lifecycle abstractions, whereas LWC executes standard JavaScript and web APIs directly within the browser runtime for improved performance.

Why this answer

Option C is correct because LWC is built on native web standards such as standard JavaScript, HTML templates, and Web Components APIs, so it leverages capabilities already present in modern browsers rather than relying on a proprietary framework layer. Option E is correct because LWC runs on the browser's native engine features (for example, standard DOM APIs and native Shadow DOM), which reduces framework overhead and generally yields better performance than Aura's framework abstractions. Options A, B, and D are not correct: LWC components do contain HTML markup in their templates, LWC is not restricted to desktop (it supports mobile and Salesforce mobile app experiences), and Aura does not use standard Shadow DOM encapsulation—it relies on its own framework-managed encapsulation rather than native Shadow DOM.

Exam trap

The trap is assuming LWC lacks HTML or is desktop-only, or that Aura uses standard Shadow DOM — candidates who haven't internalized that LWC is standards-based and Aura is framework-based pick the wrong statements.

6
MCQhard

A developer is troubleshooting an issue where a Lightning Web Component is not picking up changes to the internal fields of an object property. What is the cause of this behavior in LWC reactivity?

A.Reactive properties must be declared as constants using const instead of let.
B.LWC reactivity is shallow, so nested object property mutations require creating a new object reference or using @track.
C.The component must be wrapped in an Aura container to enable deep object tracking.
D.LWC does not support objects as reactive properties under any circumstances.
AnswerB

LWC's reactive engine tracks assignments to fields, not deep mutations, so changing a nested property leaves the original reference intact and no rerender triggers. Satisfying the stem's constraint, you must reassign a new object reference (or decorate the field with @track) for internal field changes to propagate.

Why this answer

LWC reactivity is shallow: the framework tracks assignments to the property itself, not mutations to nested fields. Changing obj.field does not trigger re-render because the object reference is unchanged. To make nested changes reactive, reassign the property with a new object (e.g., this.obj = {...this.obj, field: value}) or decorate the property with @track.

Exam trap

Salesforce-PD1 often tests the misconception that LWC provides deep reactivity like some frameworks, when in fact mutations to nested object fields require a new reference or @track.

How to eliminate wrong answers

Option A is wrong because const vs let has no bearing on reactivity; reactive properties are class fields regardless of declaration keyword. Option C is wrong because wrapping in Aura does not enable deep tracking — LWC reactivity is independent of Aura. Option D is wrong because LWC fully supports objects as reactive properties; the limitation is depth, not type.

7
MCQeasy

A developer creates a Visualforce page and wants to include standard Salesforce styling. Which attribute on the <apex:page> tag enables this?

A.lightningStylesheets="true"
B.standardStylesheets="true"
C.applyHtmlTag="true"
D.sidebar="true"
AnswerB

Setting the `standardStylesheets` attribute to true on the `<apex:page>` component directly satisfies the requirement to include standard Salesforce styling. By default, this attribute evaluates to true, which injects the core Salesforce stylesheet into the rendered HTML document. This mechanism ensures that standard user interface elements, such as input fields, labels, and buttons, automatically inherit the native Lightning or Salesforce Classic visual look and feel without requiring custom CSS definitions to be written manually by the developer.

Why this answer

The standardStylesheets attribute on the <apex:page> tag, when set to 'true', includes standard Salesforce styling (CSS) in the Visualforce page. This enables the page to use the standard Salesforce look and feel.

Exam trap

The trap is confusing standardStylesheets with lightningStylesheets, as both relate to styling but serve different purposes; candidates may pick the Lightning-specific attribute incorrectly.

How to eliminate wrong answers

Option A is wrong because lightningStylesheets is an attribute that applies Lightning Experience styles to the page, but it is not the one that includes standard Salesforce styling; it is used to make Visualforce pages look like Lightning. Option C is wrong because applyHtmlTag controls whether the page renders the <html> tag, not styling. Option D is wrong because sidebar controls the display of the sidebar, not styling.

8
Multi-Selectmedium

A developer is working with component styling and design tokens in Lightning Web Components. Which TWO practices apply when working with SLDS styling in LWC? (Choose TWO)

Select 2 answers
A.Use the !important declaration on every CSS rule to bypass Salesforce CSS encapsulation.
B.Prefer standard SLDS utility classes over custom hardcoded CSS rules for padding and margins.
C.Write global CSS stylesheets in static resources and include them in every component using standard HTML <link> tags.
D.Override component-internal shadow DOM styles from a parent component's CSS file without styling hooks.
E.Use SLDS design tokens via CSS custom properties (e.g., var(--lwc-spacingMedium)).
AnswersB, E

Salesforce Lightning Design System (SLDS) utility classes provide a predefined, scalable spacing scale that natively adheres to the platform's responsive design guidelines. Preferring these standard classes over hardcoded CSS rules satisfies the design token constraint by ensuring visual consistency across components while preventing specificity wars and style bleed. This approach leverages the underlying token architecture to automatically adapt padding and margins to varying viewport sizes and context changes without manual overrides.

Why this answer

Option B is correct because SLDS provides utility classes (such as slds-m-around_medium and slds-p-horizontal_small) that implement the design system's spacing scale consistently, so using them instead of hardcoded padding/margin values keeps components aligned with SLDS and themeable. Option E is correct because LWC exposes SLDS design tokens as CSS custom properties (for example var(--lwc-spacingMedium) or var(--lwc-colorBrand)), letting styles reference the design system's values and adapt to theming rather than duplicating literal values. Option A is wrong because sprinkling !important everywhere is an anti-pattern that fights LWC's style encapsulation and makes styles brittle; encapsulation is handled by scoping, not by !important.

Option C is wrong because global stylesheets loaded via <link> in static resources are not the recommended way to style LWC components, which rely on component-scoped CSS files. Option D is wrong because shadow DOM styles cannot be overridden from a parent component's CSS without using supported styling hooks (::part or CSS custom properties), so directly reaching into shadow DOM is not a valid practice.

Exam trap

Salesforce-PD1 often tests LWC styling encapsulation — the trap is choosing !important or global <link> CSS as a shortcut, when the correct answers are SLDS utility classes and design tokens via CSS custom properties.

9
MCQmedium

A developer is building a Lightning Web Component and wants to iterate over a list of items in the HTML template. Which directive should be used?

A.<template repeat={item in items}>
B.<aura:iteration items="{!v.items}" var="item">
C.<apex:repeat value="{!items}" var="item">
D.<template for:each={items} for:item="item">
AnswerD

The `for:each` directive provides the standard mechanism for rendering lists within Lightning Web Components. By binding the `items` array to the template and assigning each element to the `item` variable, the component dynamically generates DOM elements for every entry in the collection. This approach satisfies the requirement to iterate over a list of items efficiently, ensuring that the UI remains synchronised with the underlying JavaScript data structure while maintaining strict adherence to the declarative template syntax mandated by the framework.

Why this answer

In LWC templates, iteration is performed with the for:each directive: <template for:each={items} for:item="item">. This is the standard LWC syntax for rendering a list, and it requires a for:item attribute to name the current item (and optionally for:index for the index). It is the only correct directive among the options for LWC.

Exam trap

Salesforce PD1 often tests syntax recognition across frameworks; candidates confuse Aura's aura:iteration, Visualforce's apex:repeat, and LWC's for:each, especially when the question doesn't explicitly say 'LWC' in every option.

How to eliminate wrong answers

Option A is wrong because <template repeat={item in items}> is not valid LWC syntax — LWC does not use a repeat attribute; that resembles older templating systems. Option B is wrong because <aura:iteration> is Aura component syntax, not LWC; LWC templates cannot use aura: tags. Option C is wrong because <apex:repeat> is Visualforce syntax used in Apex pages, not in LWC.

10
MCQeasy

A developer needs to create a Lightning Web Component configuration file. What is the required file extension and naming convention?

A.componentName.cmp-meta.xml
B.componentName.xml
C.componentName.config.xml
D.componentName.js-meta.xml
AnswerD

Salesforce mandates a precise naming convention and file extension for Lightning Web Component configuration metadata files to ensure the Lightning framework recognises and deploys them correctly. To satisfy the stem's requirement for the correct format, the configuration file must combine the exact component name with the `.js-meta.xml` extension, resulting in `componentName.js-meta.xml`. This specific suffix informs the platform that the XML document defines the component's metadata, such as target device availability and design properties, distinguishing it from standard JavaScript controller or template files within the bundle.

Why this answer

The Lightning Web Component configuration file must be named `componentName.js-meta.xml` — the component's base name followed by `.js-meta.xml`. This file defines the component's metadata, including its API version, targets, and exposed properties, and the naming convention is mandatory for the framework to recognize it.

Exam trap

Salesforce PD1 often tests the confusion between Aura component metadata (`.cmp-meta.xml`) and LWC metadata (`.js-meta.xml`), since both are XML files in component bundles.

How to eliminate wrong answers

Option A is wrong because `.cmp-meta.xml` is the naming convention for Aura components, not LWC. Option B is wrong because `.xml` alone is too generic and does not follow the LWC bundle convention. Option C is wrong because `.config.xml` is not a recognized LWC metadata file extension.

11
MCQhard

A developer is using the Lightning Message Service and needs to unsubscribe from a message channel when a component is destroyed. In which lifecycle hook should unsubscribe be called?

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

The `disconnectedCallback()` lifecycle hook executes precisely when a Lightning web component is removed from the DOM, making it the correct phase to clean up subscriptions and satisfy the requirement to unsubscribe from a message channel upon component destruction. By placing the `uniquelyunsubscribe()` or equivalent removal logic inside this standard browser-aligned callback, developers prevent memory leaks, orphaned event listeners, and errors caused by messages attempting to reach a component that no longer exists in the active DOM tree.

Why this answer

The disconnectedCallback lifecycle hook fires when a component is removed from the DOM, making it the correct place to unsubscribe from a Lightning Message Channel. Failing to unsubscribe here causes memory leaks and errors when messages arrive for a destroyed component.

Exam trap

Salesforce PD1 often tests the pairing of subscribe in connectedCallback with unsubscribe in disconnectedCallback, tricking candidates into choosing renderedCallback or constructor for cleanup.

How to eliminate wrong answers

Option A is wrong because connectedCallback is where you subscribe to the message channel, not unsubscribe — unsubscribing there would immediately cancel the subscription. Option B is wrong because the constructor runs before the component is connected and before any subscription exists; unsubscribing there is meaningless. Option D is wrong because renderedCallback fires after rendering and can run multiple times; unsubscribing there would break the subscription prematurely and repeatedly.

12
Multi-Selecteasy

Which TWO tools or environments are officially supported for developing Lightning Web Components? (Choose TWO)

Select 2 answers
A.Microsoft FrontPage 2003
B.Visual Studio Code with the Salesforce Extension Pack
C.Eclipse IDE with the Force.com IDE v1 plugin
D.Salesforce CLI (sfdx / sf)
E.Dreamweaver MX with custom snippet extensions
AnswersB, D

Visual Studio Code integrated with the Salesforce Extension Pack serves as the primary officially supported local development environment for building Lightning Web Components. This combination satisfies the core platform requirement for an extensible, industry-standard code editor that natively supports Salesforce DX tooling, Lightning Language Server protocols, and integrated debugging workflows. Developers utilise this local integrated development environment to author markup, JavaScript, and CSS files before deploying the compiled source directly to an org via metadata APIs.

Why this answer

Option B is correct because Salesforce officially supports developing Lightning Web Components in Visual Studio Code using the Salesforce Extension Pack, which provides LWC-specific tooling such as syntax highlighting, code completion, and the ability to deploy and retrieve components to and from an org. Option D is correct because the Salesforce CLI (sfdx/sf) is the officially supported command-line environment for scaffolding, building, testing, and deploying LWC source, and it underpins the VS Code extensions and CI/CD workflows. The remaining options do not belong: Microsoft FrontPage 2003 (A), Eclipse with the legacy Force.com IDE v1 plugin (C), and Dreamweaver MX with custom snippets (E) are obsolete or unrelated web-authoring tools that have no official Salesforce support for LWC development.

Exam trap

Salesforce-PD1 often tests whether candidates recognize the officially supported toolchain versus legacy or unrelated IDEs that look plausible.

13
MCQhard

A developer creates a parent Lightning Web Component containing a child component. The parent needs to call a public method defined inside the child component. How is this accomplished?

A.Use the publish() method of the Lightning Message Service.
B.Update a shared reactive property passed down via @api.
C.Dispatch an event from the parent and listen to it in the child component.
D.Use this.template.querySelector('c-child-component').publicMethodName() in the parent component.
AnswerD

Directly invoking a public method on a child component from its container requires a DOM query, satisfying the requirement for upward communication from parent to child in Lightning Web Components. By utilising `this.template.querySelector('c-child-component')`, the parent obtains a direct reference to the child element instance rendered in its template. Once the component reference is secured, appending the explicitly exported function name—decorated with `@api` in the child JavaScript controller—allows the parent to execute the logic synchronously across the component boundary.

Why this answer

In LWC, a parent can call a public method on a child component by querying the child element from the parent's template and invoking the method directly. The child must expose the method with the @api decorator, and the parent uses this.template.querySelector('c-child-component') to obtain the element reference, then calls the method on it. This is the documented pattern for parent-to-child method invocation.

Exam trap

Salesforce-PD1 often tests the direction of LWC communication — the trap is picking events (which flow up) when the question asks for a parent calling a child method (which flows down via querySelector).

How to eliminate wrong answers

Option A is wrong because Lightning Message Service (LMS) is for cross-DOM communication between unrelated components (e.g., Aura and LWC, or across tabs), not for a parent calling a method on its own child. Option B is wrong because @api properties are for passing data down reactively, not for invoking behavior — updating a property does not call a method. Option C is wrong because events bubble up from child to parent, not down; dispatching from the parent and listening in the child inverts the LWC event direction.

14
Multi-Selecthard

A developer is utilizing the Lightning Message Service (LMS) to facilitate communication between an Aura component and a Lightning Web Component. Which THREE steps are required to implement LMS successfully? (Choose THREE)

Select 3 answers
A.Define a Message Channel in XML format under the /messageChannels/ directory.
B.Import the Message Channel reference into the LWC using '@salesforce/messageChannel/ChannelName__c'.
C.Create an Apex trigger to listen to the Message Channel on the server side.
D.Use publish() or subscribe() functions from the 'lightning/messageService' module.
E.Configure the component metadata file with <target>lightning__MessageChannel</target>.
AnswersA, B, D

Setting up a message channel is a foundational requirement to satisfy the constraint of establishing communication between an Aura component and a Lightning Web Component via the Lightning Message Service. This requires developers to create an XML file with the `.messageChannel-meta.xml` extension placed inside the specific `force-app/main/default/messageChannels/` directory of the Salesforce DX project. This metadata file formally defines the message channel name and its payload fields, making it available for subscription and publication across the different component frameworks.

Why this answer

Option A is correct because LMS requires a message channel to be defined as metadata in XML format inside the /messageChannels/ directory of a Salesforce DX project, which creates the ChannelName__c LightningMessageChannel used by all subscribers and publishers. Option B is correct because the LWC must import the channel reference with the exact scoped module syntax '@salesforce/messageChannel/ChannelName__c' so that publish() and subscribe() can target that specific channel. Option D is correct because the actual messaging is performed by calling publish() and subscribe() (and optionally unsubscribe()) from the 'lightning/messageService' module, which is how the Aura component and LWC exchange messages over the channel.

Option C is not needed because LMS is a client-side, browser-based messaging service and does not involve Apex triggers or server-side listeners. Option E is not required because <target>lightning__MessageChannel</target> is not a valid component target for consuming LMS; the channel is referenced via the import, not via the component metadata targets.

Exam trap

SALESFORCE-PD1 often tests LMS implementation steps, and candidates may mistakenly think that Apex triggers or component metadata targets are required, confusing LMS with other messaging patterns.

15
MCQmedium

A developer is building an Aura component and needs to include a Lightning Web Component inside it. How does the Aura markup reference the LWC?

A.<c:myLwcComponent />
B.<apex:includeComponent name="myLwcComponent" />
C.<lightning:lwc name="myLwcComponent" />
D.<aura:component include="myLwcComponent" />
AnswerA

Aura markup references a Lightning Web Component using the c: namespace followed by the component's camelCase name, so <c:myLwcComponent /> renders it. This satisfies the stem's requirement for embedding an LWC within an Aura component's markup.

Why this answer

In Aura markup, a Lightning Web Component is referenced using the c: namespace followed by the component's camelCase name, e.g., <c:myLwcComponent />. This is the documented syntax for embedding an LWC inside an Aura component. The c: namespace maps to the default namespace for custom components in the org.

Exam trap

Salesforce-PD1 often tests whether candidates confuse Visualforce tags (apex:), Aura base components (lightning:), and the c: namespace used for custom Aura and LWC references.

How to eliminate wrong answers

Option B is wrong because <apex:includeComponent> is a Visualforce tag for including Visualforce components, not for embedding LWCs in Aura. Option C is wrong because <lightning:lwc> is not a valid Aura tag — there is no such base component for embedding LWCs. Option D is wrong because <aura:component> is the root tag that defines an Aura component itself, and it has no 'include' attribute for referencing other components.

16
Multi-Selectmedium

Which TWO conditions must be met for an Apex method to be wired using the @wire service in an LWC? Choose 2 answers.

Select 2 answers
A.The Apex method must return a DML operation result.
B.The Apex method must be public or global and static.
C.The Apex method must return a PageReference.
D.The Apex method must be annotated with @AuraEnabled(cacheable=true).
E.The Apex method must be asynchronous using @future.
AnswersB, D

To satisfy the visibility and scope requirements of the `@wire` service, an Apex method must be explicitly declared as either `public` or `global` alongside the `static` keyword. This specific modifier combination ensures the Lightning Web Component's client-side JavaScript engine can successfully access and invoke the server-side controller method asynchronously without requiring an instantiated object context.

Why this answer

Option B is correct because an Apex method exposed to Lightning Web Components via @wire must be declared public or global and static, since the wire adapter invokes it without an instance context. Option D is correct because the method must be annotated with @AuraEnabled(cacheable=true); the cacheable=true setting is what allows the wire service to call the method and cache its results on the client. Options A, C, and E are incorrect because a wired Apex method does not need to return a DML result, does not need to return a PageReference, and must not be asynchronous via @future — @future methods cannot be wired and cannot be marked cacheable.

Exam trap

Salesforce-PD1 often tests the misconception that any @AuraEnabled Apex method can be wired, when in fact cacheable=true is a hard requirement that also forbids DML and callouts.

17
MCQhard

A developer creates a custom LWC that wraps child components. The developer needs to pass styling from the parent component into specific slots of the child component. Which CSS selector should be used inside the child component to style content passed into a slot?

A.:content
B.:scope
C.:host
D.::slotted()
AnswerD

::slotted() targets elements assigned to a slot from the parent's light DOM, letting the child component style slotted content while respecting shadow DOM encapsulation. It satisfies the stem's constraint of passing styling into specific slots, unlike :host or ::part, which address the host element or exposed parts respectively.

Why this answer

The ::slotted() pseudo-class selector is used in the child component's stylesheet to target nodes slotted into a <slot> element.

18
Multi-Selectmedium

A developer is implementing communication in Lightning Web Components. Which TWO mechanisms are valid for passing data or messages between components? (Choose TWO)

Select 2 answers
A.Directly assigning properties on child components from sibling components.
B.Dispatching and listening to CustomEvent instances in parent-child hierarchies.
C.Using application events via $A.get('e.force:event') in LWC.
D.Modifying global window variables shared across component scopes.
E.Using Lightning Message Service (LMS) to publish and subscribe across the DOM.
AnswersB, E

Custom events provide the standard DOM mechanism for communication moving upwards through a parent-child component hierarchy in Lightning Web Components. By dispatching a `CustomEvent` from a child component and listening for it via an inline event handler on the parent template, developers satisfy the directional constraint of passing data from child to parent. This native browser event model bubbles up the component tree, enabling decoupled upward data flows without requiring shared state or global pub-sub structures.

Why this answer

Option B is correct because in Lightning Web Components, a child component can dispatch a CustomEvent (via this.dispatchEvent(new CustomEvent(...))) that bubbles up the DOM, and a parent component can listen for it using an event handler in its template or with addEventListener, making it the standard mechanism for child-to-parent communication. Option E is correct because Lightning Message Service (LMS) provides a publish-subscribe API (lightning/messageService with publish() and subscribe()) that lets components communicate across the DOM—including between unrelated components, across different component trees, and even with Aura components—by publishing to a message channel. Option A is not valid because a component cannot directly reach into a sibling component's properties; siblings have no direct reference to each other and must communicate through a common parent or a message service.

Option C is not valid because $A.get('e.force:event') is an Aura framework API for application events, and LWC does not support Aura application events; LWC uses CustomEvent or LMS instead. Option D is not valid because LWC components run in a secure, encapsulated environment (Lightning Web Security/synthetic shadow DOM) and sharing state through global window variables is an anti-pattern that breaks encapsulation and is not a supported communication mechanism.

Exam trap

The trap is confusing Aura application events with LWC mechanisms — candidates who learned Aura pick $A.get('e.force:event'), but LWC has no application events and instead relies on CustomEvent and Lightning Message Service.

19
MCQmedium

A developer needs to display a toast notification in a Lightning Web Component when a record is successfully saved. Which module should the developer import?

A.import { Toast } from 'lightning/toast';
B.import ShowToast from 'force:showToast';
C.import { ShowToastEvent } from 'lightning/platformShowToastEvent';
D.import { showNotification } from 'lightning/notificationsLibrary';
AnswerC

Displaying a toast notification within a Lightning Web Component requires importing the `ShowToastEvent` constructor directly from the `lightning/platformShowToastEvent` module. This specific module provides the imperative JavaScript API necessary to construct and dispatch the user interface notification event when a record is successfully saved, thereby satisfying the requirement to alert users natively without relying on custom HTML overlays or third-party libraries.

Why this answer

Lightning Toast notifications are triggered by importing ShowToastEvent from 'lightning/platformShowToastEvent'.

20
MCQeasy

Which tag is used in Visualforce to output field labels and values dynamically based on sObject field definitions?

A.<apex:field>
B.<apex:inputField>
C.<apex:outputText>
D.<apex:outputField>
AnswerD

`<apex:outputField>` satisfies the requirement to output field values dynamically based on sObject field definitions because it automatically renders the correct formatting and type-specific attributes—such as currency symbols, date formats, or picklist values—directly from the underlying field metadata. Unlike standard output components that require explicit formatting definitions, this tag inspects the schema definition of the specified sObject field at runtime, ensuring that the displayed value respects user-level field-level security and profile permissions without additional controller logic.

Why this answer

<apex:outputField> renders field values with correct formatting and related labels.

21
Multi-Selecthard

A developer is troubleshooting lifecycle hooks and rendering behavior in a Lightning Web Component. Which THREE statements are correct regarding LWC lifecycle execution order? (Choose THREE)

Select 3 answers
A.The constructor() is invoked before the component is inserted into the DOM.
B.renderedCallback() only executes once during the lifetime of the component.
C.connectedCallback() is invoked when the component is inserted into the DOM.
D.disconnectedCallback() is invoked when the component is removed from the DOM.
E.renderedCallback() is invoked before connectedCallback().
AnswersA, C, D

The `constructor()` hook executes as the very first step in the component lifecycle, running entirely in memory prior to the component being inserted into the DOM. This satisfies the strict initialization constraint regarding DOM insertion order, ensuring that reactive properties and base state variables are properly instantiated before template evaluation and rendering occur in the browser.

Why this answer

Option A is correct because the constructor() lifecycle hook runs first, during component instantiation, before the element is attached to the DOM, making it the right place for initializing state but not for DOM access. Option C is correct because connectedCallback() fires when the component is inserted into the DOM, which is why it is used for DOM manipulation, subscribing to events, or fetching data. Option D is correct because disconnectedCallback() fires when the component is removed from the DOM, making it the appropriate hook for cleanup such as unsubscribing from events or clearing timers.

Option B is incorrect because renderedCallback() runs after every render of the component, not just once, so it can execute multiple times as reactive properties change. Option E is incorrect because renderedCallback() runs after the component is connected and rendered, so it cannot execute before connectedCallback().

Exam trap

Salesforce-PD1 often tests the misconception that renderedCallback() runs only once, but it actually runs after every render, leading candidates to incorrectly select option B.

22
MCQeasy

What is the correct syntax to reference a custom label in a Lightning Web Component JavaScript file?

A.Label.get('LabelName')
B.System.Label.LabelName
C.$Label.LabelName
D.import labelName from '@salesforce/label/LabelName';
AnswerD

To correctly reference a custom label within a Lightning Web Component JavaScript file, developers must utilise the scoped module import syntax provided by the Salesforce platform. The specifier string `@salesforce/label/LabelName` tells the Lightning Web Component compiler to resolve the reference against the organisation's metadata, securely importing the specified label as an ES6 module binding. This specific module path pattern satisfies the strict compiler constraint for accessing custom labels on the client side without exposing unauthorised backend resources.

Why this answer

In Lightning Web Components (LWC), custom labels are imported using the standard ES6 import syntax from the special '@salesforce/label' module. The correct syntax is `import labelName from '@salesforce/label/LabelName';`, where `LabelName` is the API name of the custom label. This import makes the label's value available as a JavaScript variable that can be used in the component's template or logic.

This approach is specific to LWC and differs from Aura or Visualforce.

Exam trap

Salesforce PD1 often tests the confusion between syntaxes for different Salesforce frameworks (Aura, Visualforce, LWC), so candidates may incorrectly choose Aura's `$Label.LabelName` or Visualforce's `System.Label.LabelName` instead of the LWC-specific import statement.

How to eliminate wrong answers

Option A is wrong because `Label.get('LabelName')` is not valid LWC syntax; it resembles Aura's `$A.get('$Label.c.LabelName')` but is incomplete and incorrect. Option B is wrong because `System.Label.LabelName` is Visualforce syntax, not JavaScript. Option C is wrong because `$Label.LabelName` is Aura component syntax, not LWC.

Option D is correct because it uses the proper ES6 import from the '@salesforce/label' scoped module.

23
MCQhard

A developer needs to pass data from a child Lightning Web Component to a parent Lightning Web Component up the component hierarchy. What is the standard mechanism to achieve this?

A.Use the @api decorator in the child component to expose a public method that the parent can call directly.
B.Dispatch a CustomEvent in the child and handle it in the parent's template using an event listener directive.
C.Publish a message using the Lightning Message Service from the child and subscribe in the parent.
D.Mutate a shared global reactive property imported from a common utility JavaScript module.
AnswerB

Lightning Web Components communicate up the hierarchy by having the child component dispatch a standard JavaScript `CustomEvent`. This satisfies the requirement to pass data from a child to a parent up the component containment tree. The parent component then listens for this dispatched custom event directly within its declarative HTML template using an event listener directive, such as `onmyevent`, allowing it to capture the payload via the event's `detail` property and handle the data flow securely.

Why this answer

Child-to-parent communication in LWC is achieved by dispatching a custom event using CustomEvent and listening to it in the parent template.

24
MCQmedium

A developer needs to include a third-party style sheet in a Lightning Web Component. What is the standard way to load CSS styles that are stored as a static resource?

A.import { loadStyle } from 'lightning/platformResourceLoader';
B.Declaring the stylesheet in the component's metadata configuration file under <stylesheets>.
C.import stylesheet from '@salesforce/resourceUrl/myCSS';
D.Using a standard <link> tag pointing directly to the static resource URL in the HTML template.
AnswerA

Using `loadStyle` from `lightning/platformResourceLoader` resolves the static resource URL and injects the stylesheet into the component's DOM at runtime, satisfying the requirement to load third-party CSS stored as a static resource. It is the platform-provided API designed precisely for this, handling resource resolution without manual URL construction.

Why this answer

The platformResourceLoader module provides the loadStyle function, which loads a CSS file from a static resource into a Lightning Web Component. This is the standard way to include third-party stylesheets stored as static resources.

Exam trap

Salesforce PD1 often tests the correct module for loading static resources; candidates may confuse loadStyle with loadScript or incorrectly think they can use a <link> tag in LWC templates.

How to eliminate wrong answers

Option B is wrong because there is no <stylesheets> metadata configuration for LWC; styles are typically loaded via loadStyle or imported in the component's CSS file. Option C is wrong because importing a stylesheet from @salesforce/resourceUrl is not valid for CSS; that is used for referencing static resources like images or JavaScript. Option D is wrong because using a <link> tag directly in the HTML template is not supported in LWC; the framework sanitizes and restricts such tags.

25
MCQeasy

Which CSS methodology forms the foundation of the styling architecture in Salesforce Lightning Design System (SLDS)?

A.Bootstrap grid standards
B.BEM (Block Element Modifier)
C.OOCSS exclusively without modifiers
D.Tailwind utility prefixes
AnswerB

BEM provides the naming convention that satisfies the SLDS requirement for modular, scalable styling architecture. By structuring classes into blocks, elements, and modifiers, this methodology prevents CSS specificity conflicts and ensures that components remain encapsulated within the Salesforce ecosystem. This hierarchical approach allows developers to maintain a consistent visual language across complex applications, as it enforces a strict relationship between the structural components and their individual states, effectively decoupling the styling logic from the underlying DOM structure.

Why this answer

Salesforce Lightning Design System (SLDS) is built on the BEM (Block Element Modifier) CSS naming methodology, which structures class names as block__element--modifier to create predictable, reusable, and scoped styles. SLDS class names such as slds-button, slds-button__icon, and slds-button_brand directly reflect BEM conventions. This methodology underpins SLDS's modularity and maintainability across components.

Exam trap

SALESFORCE-PD1 often tests whether candidates recognize SLDS's BEM foundation versus other popular CSS methodologies like Bootstrap, OOCSS, or Tailwind, so familiarity with SLDS class naming is essential.

How to eliminate wrong answers

Option A is wrong because Bootstrap's grid standards are a separate framework's layout system; SLDS has its own grid (slds-grid) and is not built on Bootstrap. Option C is wrong because OOCSS alone (without modifiers) is insufficient — SLDS explicitly uses modifiers (the 'M' in BEM) to express variants like brand, inverse, or destructive. Option D is wrong because Tailwind's utility-first prefixes are a different methodology entirely; SLDS uses semantic component classes, not atomic utility classes.

26
MCQmedium

A developer is building a Lightning Web Component and needs to dispatch a custom event. Which constructor should be used to create the event?

A.Event
B.AuraEvent
C.CustomEvent
D.LightningEvent
AnswerC

`CustomEvent` is the correct constructor to use when building a Lightning Web Component because it satisfies the requirement to dispatch a custom event with associated data. Unlike the standard `Event` constructor, which only allows a name and basic bubbling configuration, `CustomEvent` includes a `detail` property within its options object. This enables the developer to pass custom payloads up the component hierarchy to parent elements, fulfilling the exact data-transfer constraint specified in the stem.

Why this answer

In Lightning Web Components, custom events are created using the CustomEvent constructor. The syntax is `new CustomEvent('eventName', { detail: {...} })`. This is the standard DOM API for creating custom events, and LWC uses it to dispatch events from child to parent components.

Exam trap

The trap is confusing the CustomEvent constructor with other event-related APIs, especially for developers with Aura background who might look for an Aura-specific event constructor.

How to eliminate wrong answers

Option A is wrong because Event is the base constructor for all events, but it does not allow passing a detail payload; CustomEvent is the correct one for custom events with data. Option B is wrong because AuraEvent is not a valid constructor; Aura components use $A.get('e.c:MyEvent') or similar, but LWC uses CustomEvent. Option D is wrong because LightningEvent is not a valid constructor; it is a misnomer.

27
MCQmedium

A developer needs to navigate to a record detail page from a Lightning Web Component. Which service should be used?

A.lightning/pageReference
B.window.location.href
C.lightning/uiRecordApi
D.lightning/navigation
AnswerD

The `lightning/navigation` module provides the `NavigationMixin` class, which is the standard mechanism for triggering programmatic navigation within Lightning Web Components. By extending a component with this mixin, a developer gains access to the `[NavigationMixin.Navigate]` method, enabling the redirection to a specific record detail page using a `standard__recordPage` page reference type. This approach satisfies the requirement to transition between views within the Salesforce environment, ensuring the application remains compliant with the platform's internal routing architecture rather than relying on external authentication services like Microsoft Entra ID.

Why this answer

The lightning/navigation service provides the NavigationMixin, which allows Lightning Web Components to navigate to record detail pages, list views, and other pages using standard navigation. It is the recommended way to navigate within Salesforce.

Exam trap

Salesforce PD1 often tests the confusion between navigation and other services like uiRecordApi; candidates may incorrectly choose window.location.href for simplicity, but that breaks the SPA model.

How to eliminate wrong answers

Option A is wrong because lightning/pageReference is not a service; it is a type used with navigation to generate a page reference. Option B is wrong because using window.location.href bypasses the Lightning navigation framework and can cause full page reloads, losing the SPA experience. Option C is wrong because lightning/uiRecordApi is used for record operations like create, update, and delete, not for navigation.

28
MCQmedium

A developer wants to conditionally display an HTML element in a Lightning Web Component template based on a boolean property named 'isVisible'. Which directive should be used?

A.renderIf
B.aura:if
C.v:if
D.lwc:if
AnswerD

`lwc:if` is the correct directive to conditionally render an HTML element in a Lightning Web Component template based on the boolean property `isVisible`. This directive directly satisfies the requirement for conditional rendering in modern Salesforce development, evaluating the truthiness of the specified JavaScript property to determine whether the host element and its children are inserted into or removed from the DOM.

Why this answer

lwc:if is the modern conditional directive in LWC.

29
MCQmedium

A developer needs to configure a Lightning Web Component to be available for use on Lightning Record Pages. Which configuration entry must be present in the component's metadata file (.js-meta.xml)?

A.lightning__AppPage
B.lightning__GlobalAction
C.lightning__RecordPage
D.lightning__UtilityBar
AnswerC

Including `lightning__RecordPage` within the `targets` section of the component's metadata file explicitly enables the component to appear in the Lightning App Builder for record-specific pages. This configuration satisfies the requirement to make the component available for use on Lightning Record Pages by registering it within the Salesforce platform's target framework. Without this specific entry, the component remains hidden from the Lightning App Builder interface, preventing developers from dragging and dropping it onto the page layout.

Why this answer

To expose a Lightning Web Component on Lightning Record Pages, the .js-meta.xml file must include the <target> lightning__RecordPage. This target tells the Lightning framework that the component is eligible to be dragged onto record page layouts in Lightning App Builder. Other targets correspond to different surfaces such as app pages, home pages, or utility bars.

Exam trap

Salesforce PD1 often tests the confusion among lightning__ targets, leading candidates to select lightning__AppPage or lightning__UtilityBar when the question specifically asks about Lightning Record Pages.

How to eliminate wrong answers

Option A is wrong because lightning__AppPage exposes the component for Lightning App Pages, not record pages. Option B is wrong because lightning__GlobalAction exposes the component as a global quick action, not a record page component. Option D is wrong because lightning__UtilityBar exposes the component in the utility bar at the bottom of the Lightning app, not on record pages.

30
MCQeasy

Which tag is used in Visualforce to include custom CSS stylesheets?

A.<apex:stylesheet>
B.<link rel="stylesheet" ...>
C.<apex:css>
D.<apex:style>
AnswerA

Visualforce pages utilise the `<apex:stylesheet>` component specifically to reference external Cascading Style Sheet files stored as Static Resources within the Salesforce organisation. This tag satisfies the exact requirement stated in the stem by rendering the appropriate HTML `<link>` tag pointing to the static resource URL via `$Resource`, allowing developers to cleanly separate presentation styling from application logic.

Why this answer

<apex:stylesheet> is used to include external CSS files in Visualforce.

31
MCQmedium

A developer needs to format a currency value according to the user's locale in a Lightning Web Component HTML template. Which base component should be used?

A.lightning-input
B.apex:outputText
C.ui:outputCurrency
D.lightning-formatted-number
AnswerD

`lightning-formatted-number` satisfies the requirement to format a currency value according to the user's locale by accepting a `style="currency"` attribute alongside a `currency-code` attribute. When rendered in a Lightning Web Component HTML template, this base component automatically detects the current user's locale settings from the Salesforce environment and applies the correct currency symbol, decimal separators, and digit grouping without requiring manual string manipulation in JavaScript.

Why this answer

lightning-formatted-number is the correct base component because it formats numeric values, including currency, according to the user's locale. It supports a 'format-style' attribute set to 'currency' and automatically applies the correct currency symbol, decimal separator, and grouping based on the user's locale settings. This is the standard LWC component for locale-aware number formatting.

Exam trap

SALESFORCE-PD1 often tests the distinction between Aura and LWC base components, and candidates may mistakenly choose ui:outputCurrency because it sounds like a currency formatter, but it is not available in LWC.

How to eliminate wrong answers

Option A is wrong because lightning-input is used for user input fields, not for displaying formatted output. Option B is wrong because apex:outputText is an Aura component, not an LWC base component, and does not provide locale-aware currency formatting. Option C is wrong because ui:outputCurrency is a legacy Aura component from the ui namespace, not available in LWC.

32
MCQeasy

A developer needs to create a custom tab for a Lightning Web Component so it can be navigated to from the App Launcher. What type of custom tab must be created?

A.Lightning Component Tab
B.Visualforce Tab
C.Object Tab
D.Web Tab
AnswerA

To surface a Lightning Web Component within the App Launcher navigation framework, developers must configure a Lightning Component Tab. This specific tab type directly satisfies the stem requirement by exposing bundle components that implement the `lightning__Tab` target interface directly to the Salesforce navigation architecture, rendering them accessible as standalone applications or navigational items without requiring wrapper Aura components.

Why this answer

Lightning component tabs allow Lightning Web Components and Aura components to be exposed as tabs.

33
MCQhard

A developer is working with a Lightning Web Component and needs to access a child component's public method from the parent component. How is this achieved?

A.Bind the child method to a public @api property on the parent.
B.Fire an application event from the parent to the child.
C.Use document.getElementById() to find the child element.
D.Invoke the method directly on the child element reference obtained via template.querySelector().
AnswerD

Lightning Web Components use standard DOM encapsulation, meaning parent components cannot directly access child internals by default. To satisfy the requirement of invoking a child component's public method from a parent, the child must explicitly expose the method using the `@api` decorator. The parent then obtains a direct reference to the child DOM element using `this.template.querySelector()` and invokes the exposed method directly on that element reference, successfully bridging the shadow DOM boundary while maintaining proper encapsulation principles.

Why this answer

Public methods on child components must be decorated with @api and invoked via this.template.querySelector().methodName().

34
MCQeasy

A developer is styling a Lightning Web Component using the Salesforce Lightning Design System (SLDS). To ensure the component adheres to the standard styling guidelines for spacing, what should the developer use?

A.SLDS standard spacing utility classes.
B.Inline styles directly in the HTML template.
C.Standard HTML blockquote tags with custom margin properties.
D.Hardcoded pixel values in the component's CSS file.
AnswerA

Utilising Salesforce Lightning Design System (SLDS) standard spacing utility classes directly satisfies the requirement to adhere to standard styling guidelines for spacing by providing predefined CSS token-based margins and paddings. These utility classes—such as `slds-m-around_medium`—ensure consistent layout dimensions that automatically scale correctly across different viewports and maintain strict compliance with Salesforce design tokens, preventing hardcoded pixel values from violating responsive UI standards.

Why this answer

SLDS provides a documented set of spacing utility classes (e.g., slds-m-around_medium, slds-p-horizontal_small) that enforce the design system's standardized spacing scale. Using these utilities guarantees visual consistency across components and future-proofs the UI against SLDS token changes. This is the officially recommended approach for adhering to SLDS styling guidelines.

Exam trap

The trap here is confusing 'styling freedom' with 'styling correctness' — candidates who are used to writing raw CSS may pick inline styles or hardcoded pixels, not realizing SLDS explicitly mandates utility classes for spacing consistency.

How to eliminate wrong answers

Option B is wrong because inline styles bypass the SLDS design tokens, are hard to maintain, and cannot be overridden by theming or SLDS updates. Option C is wrong because blockquote is a semantic HTML element for quotations, not a spacing mechanism, and custom margins on it violate SLDS conventions. Option D is wrong because hardcoded pixel values ignore the SLDS spacing scale, break responsive design, and won't adapt when SLDS design tokens change.

35
MCQeasy

Which lifecycle hook in a Lightning Web Component runs after every render of the component?

A.constructor()
B.connectedCallback()
C.renderedCallback()
D.render()
AnswerC

`renderedCallback()` executes every time the component finishes rendering its HTML template, directly satisfying the requirement to run after every render cycle. As a unique lifecycle hook in the Lightning Web Component framework, it fires after both initial insertion into the DOM and any subsequent re-renders triggered by reactive property updates. This makes it the appropriate mechanism for performing post-render logic, manipulating DOM elements, or integrating with third-party libraries that rely on the latest DOM state.

Why this answer

renderedCallback() is the LWC lifecycle hook invoked after every render of the component, including the initial render and any subsequent re-renders triggered by reactive property changes. It is the correct place to perform DOM manipulation or logic that depends on the rendered output, though developers must guard against infinite loops by checking whether work has already been done.

Exam trap

The trap is confusing connectedCallback() with renderedCallback() — candidates who remember 'callback runs when component loads' pick connectedCallback, but only renderedCallback() runs after every render, which is what the question specifies.

How to eliminate wrong answers

Option A is wrong because constructor() runs once when the component instance is created, before any rendering, and cannot access the DOM or the component's rendered elements. Option B is wrong because connectedCallback() fires once when the component is inserted into the DOM, not after every render — it is for initialization logic like fetching data, not post-render work. Option D is wrong because render() is not a standard LWC lifecycle hook; LWC uses a declarative template and does not expose a render() method like React or Aura's render().

36
MCQmedium

A developer is building a Lightning Web Component that displays a toast notification when a user successfully saves a record. Which module should the developer import to use the ShowToastEvent?

A.lightning/notifications
B.lightning/toast
C.lightning/messageService
D.lightning/platformShowToastEvent
AnswerD

The lightning/platformShowToastEvent module provides the ShowToastEvent class, which is used to display toast notifications in Lightning Experience and the Salesforce mobile app. Importing this module allows the developer to dispatch a toast event with configurable title, message, variant, and mode, ensuring proper user feedback.

Why this answer

To display a toast notification in a Lightning Web Component, the developer must import ShowToastEvent from lightning/platformShowToastEvent. This event is then dispatched with the appropriate parameters. Other modules serve different purposes and do not provide toast functionality.

Therefore, the correct import is from lightning/platformShowToastEvent.

Exam trap

The trap here is guessing a module name that sounds plausible, such as lightning/toast, instead of using the actual module lightning/platformShowToastEvent.

37
MCQeasy

A developer wants to style a Lightning Web Component using the Salesforce Lightning Design System (SLDS). What is the recommended way to include SLDS styling?

A.Use standard SLDS utility classes directly in the component's HTML template.
B.Import the full SLDS stylesheet explicitly as a static resource.
C.Apply standard Bootstrap classes to match Salesforce themes.
D.Use inline styles exclusively for all components.
AnswerA

Using standard SLDS utility classes directly within the HTML template satisfies the recommended approach for styling Lightning Web Components without importing external stylesheets or custom static resources. The Salesforce Lightning Design System is natively available in the platform's component architecture, meaning developers can apply predefined design tokens and layout classes straight to the markup. This native integration ensures optimal performance, consistent branding aligned with Salesforce guidelines, and automatic adaptation to theme updates without requiring manual CSS maintenance.

Why this answer

Lightning Web Components are designed to work natively with SLDS, and the recommended approach is to apply SLDS utility classes (like slds-button, slds-grid, slds-m-around_medium) directly in the component's HTML template. Salesforce automatically makes SLDS available to LWC without any import, and using utility classes ensures visual consistency with the Lightning Experience and future SLDS updates.

Exam trap

Salesforce PD1 often tests the misconception that SLDS must be manually imported as a static resource in LWC, when it is actually available by default and should be used via utility classes.

How to eliminate wrong answers

Option B is wrong because importing the full SLDS stylesheet as a static resource is unnecessary and discouraged — SLDS is already globally available in LWC, and manually importing it can cause version drift and conflicts. Option C is wrong because Bootstrap is a third-party CSS framework not aligned with Salesforce's design system; mixing it with SLDS breaks visual consistency and can cause style conflicts. Option D is wrong because inline styles bypass SLDS entirely, are hard to maintain, cannot leverage SLDS design tokens, and violate the component-based styling model LWC promotes.

38
Multi-Selecteasy

Which TWO features are provided out-of-the-box by Visualforce when building standard user interfaces? (Choose TWO)

Select 2 answers
A.Client-side reactive shadow DOM encapsulation.
B.Automatic compilation of TypeScript into native browser bytecode.
C.Automatic enforcement of CRUD and FLS when using standard controllers.
D.Real-time bidirectional WebSocket synchronization across all connected browser tabs.
E.Built-in view state management for form submission and page state tracking.
AnswersC, E

Standard controllers in Visualforce automatically enforce Object-Level Security (CRUD) and Field-Level Security (FLS) to satisfy the requirement for built-in security enforcement in standard user interfaces. When data is accessed or rendered through standard controller bindings, the platform implicitly checks the running user's permissions, preventing unauthorized access to restricted sObjects and fields without requiring explicit Apex queries or manual security checks in the controller extension.

Why this answer

Option C is correct because Visualforce standard controllers and standard list controllers automatically enforce object-level CRUD permissions and field-level security (FLS) for the running user, so developers get secure data access without writing manual permission checks. Option E is correct because Visualforce automatically maintains the view state (the encrypted, serialized page state stored in the __VIEWSTATE hidden field) across postbacks, preserving form input and component state during form submission and page navigation. Options A, B, and D are not Visualforce out-of-the-box features: Visualforce does not provide client-side reactive shadow DOM encapsulation, it does not compile TypeScript into native browser bytecode (it renders HTML/CSS/JS server-side), and it does not offer real-time bidirectional WebSocket synchronization across browser tabs.

Exam trap

Salesforce PD1 often tests the misconception that custom controllers also enforce CRUD/FLS automatically like standard controllers, when in fact only standard controllers provide that enforcement out of the box.

39
Multi-Selecteasy

Which TWO actions can a developer perform using standard Visualforce controllers? Choose 2 answers.

Select 2 answers
A.Write complex multi-object business logic with custom SQL-like joins.
B.Perform standard save, delete, and cancel database operations without writing custom Apex code.
C.Instantiate custom web service callouts automatically.
D.Access field values of the record being viewed or edited.
E.Override standard page layouts without any configuration.
AnswersB, D

Standard Visualforce controllers inherently provide built-in controller methods that execute standard database operations such as `save()`, `delete()`, and `cancel()` directly against the associated record without requiring any custom Apex controller logic. This capability directly satisfies the requirement in the question stem to perform standard database operations without writing custom Apex code, leveraging the pre-built functionality that maps user interface actions straight to the underlying Salesforce database layer.

Why this answer

Option B is correct because standard Visualforce controllers (such as StandardController) expose built-in save, delete, and cancel actions that automatically handle DML on the associated record, so a developer can wire buttons like <apex:commandButton action="{!save}"/> without writing any custom Apex. Option D is correct because a standard controller binds the Visualforce page to a single sObject record and exposes its fields through merge expressions such as {!Account.Name} or {!Contact.Phone}, letting the page read and display the viewed or edited record's field values. Option A is not correct because standard controllers cannot express custom SQL-like joins or complex multi-object business logic; that requires custom Apex (SOQL/SOSL or Apex controllers).

Option C is not correct because standard controllers do not automatically instantiate or invoke web service callouts; callouts must be coded explicitly in Apex. Option E is not correct because overriding standard page layouts is done through configuration (Lightning App Builder, page layout assignment, or Visualforce page overrides), not by a standard controller action.

Exam trap

The trap here is conflating the standard controller's built-in CRUD and record-field access with capabilities that actually require custom Apex, such as multi-object logic, callouts, or layout overrides — candidates often overestimate what the standard controller can do out of the box.

40
MCQeasy

Which SLDS utility class should a developer use to add a standard margin around a container?

A.slds-grid
B.slds-m-around_medium
C.slds-padding_medium
D.slds-margin-all
AnswerB

The `slds-m-around_medium` utility class directly satisfies the requirement to add a standard margin around a container by applying a medium-sized spacing scale uniformly across all four sides. Salesforce Lightning Design System (SLDS) naming conventions structure spacing modifiers using the property prefix (`m` for margin), the modifier type (`around` for all sides), and the size specifier (`medium`), which ensures consistent layout dimensions and aligns precisely with the standard spacing constraint specified in the stem.

Why this answer

SLDS spacing classes follow the pattern slds-m-{sides}-{size}.

41
Multi-Selecteasy

A developer is creating a Lightning Web Component that needs to interact with Salesforce data using Lightning Data Service. Which TWO wire adapters are natively available in the @salesforce/apex or lightning/ui* modules for basic record operations? (Choose TWO)

Select 2 answers
A.getAccountList from 'lightning/accountApi'
B.getRecordUi from 'lightning/uiRecordApi'
C.getRecord from 'lightning/uiRecordApi'
D.fetchRecord from 'lightning/recordStore'
E.queryDatabase from 'lightning/database'
AnswersB, C

`getRecordUi` from the `lightning/uiRecordApi` module is natively available to handle basic record operations through Lightning Data Service. It directly satisfies the stem requirement by providing a wire adapter capable of retrieving layout and record data simultaneously for specified objects and record IDs, allowing developers to efficiently query and display contextual Salesforce record data without writing custom Apex controllers.

Why this answer

Option B, getRecordUi from 'lightning/uiRecordApi', is correct because it is a native Lightning Data Service wire adapter that retrieves record layout, metadata, and field data for one or more records, commonly used with User Interface API responses. Option C, getRecord from 'lightning/uiRecordApi', is also correct because it is the standard Lightning Data Service wire adapter for fetching a single record's fields by record ID and fields, without writing Apex. The other options are not valid native wire adapters: getAccountList from 'lightning/accountApi' does not exist, fetchRecord from 'lightning/recordStore' is not a Salesforce module, and queryDatabase from 'lightning/database' is not a Lightning Data Service adapter.

Exam trap

Salesforce-PD1 often tests whether candidates know the exact module names and adapter names — fabricated modules like lightning/accountApi or lightning/database are designed to look plausible.

42
MCQeasy

A developer is creating a Visualforce page that overrides the standard Account View action. Which attribute must be included in the <apex:page> tag to ensure standard controller functionality?

A.controller="Account"
B.object="Account"
C.recordId="Account"
D.standardController="Account"
AnswerD

To satisfy the stem's requirement of overriding the standard Account View action while retaining core platform functionality, the `<apex:page>` tag must explicitly declare `standardController="Account"`. This attribute instantiates the built-in Account controller, granting the Visualforce page immediate access to standard record data, navigation methods, and extensions without requiring custom Apex logic to query the database. Omitting this specific attribute would strip away default CRUD operations and standard field bindings natively associated with the Account object.

Why this answer

The standardController attribute on <apex:page> binds the page to a Salesforce standard controller for a specific object, giving the page access to that object's fields, standard actions, and record context. When overriding a standard action like Account View, the page must declare standardController="Account" so the platform knows which object's standard controller to instantiate and how to pass the record Id. Without it, the page has no controller and cannot leverage standard save, view, or record-binding behavior.

Exam trap

The trap here is confusing controller (custom Apex class) with standardController (built-in object controller) — candidates who see 'Account' assume either attribute works, but only standardController provides the built-in record context needed for a standard action override.

How to eliminate wrong answers

Option A is wrong because controller="Account" attempts to reference a custom Apex controller class named Account, which does not exist and would not provide standard controller behavior. Option B is wrong because object="Account" is not a valid <apex:page> attribute — the object is inferred from the standardController, not set directly. Option C is wrong because recordId="Account" is not a valid attribute; the record Id is passed via the URL parameter id and read through the standard controller, not by assigning an object name to recordId.

43
Multi-Selecthard

A developer is implementing error handling for an imperative Apex call in a Lightning Web Component. Which THREE properties or techniques are standard for catching and inspecting errors returned from Apex promises? (Choose THREE)

Select 3 answers
A.Using a .catch(error => { ... }) block on the returned promise.
B.Using try/catch blocks with asynchronous/await syntax when calling imperative Apex.
C.Reading error.stackTrace to automatically rollback database transactions on the client.
D.Calling error.retry() to automatically re-execute the failed database transaction.
E.Inspecting error.body.message to retrieve the specific error message thrown by Apex.
AnswersA, B, E

Imperative Apex calls in Lightning Web Components return standard JavaScript promises, making a `.catch()` block essential for handling rejected asynchronous operations. When an Apex method throws an exception or encounters a system failure, the returned promise rejects rather than resolves, directly satisfying the requirement in the question stem to catch and inspect errors returned from Apex promises. Developers use this technique to access the error object, which typically contains a body with message details for debugging.

Why this answer

Option A is correct because imperative Apex calls return a JavaScript Promise, and attaching a .catch(error => { ... }) handler is the standard way to intercept and inspect a rejected promise when using .then() chaining. Option B is correct because async/await syntax wraps the promise so that a thrown Apex error surfaces as an exception inside a try/catch block, which is the recommended pattern for imperative Apex in LWC. Option E is correct because Apex errors are surfaced to the client as an error object whose body.message property contains the specific message thrown by the Apex method (for example, from AuraHandledException or a DML exception).

Option C is incorrect because error.stackTrace is a client-side JavaScript stack trace and cannot roll back server-side database transactions; DML rollback happens automatically on the server when an Apex transaction fails. Option D is incorrect because there is no error.retry() method on Apex error objects, and re-executing a failed database transaction is not an automatic client-side behavior.

Exam trap

Salesforce-PD1 often tests the misconception that client-side error objects can rollback server transactions or auto-retry — candidates pick options like `error.stackTrace` rollback or `error.retry()` because they sound plausible, but these are not real APIs.

44
Multi-Selecthard

A developer is reviewing a Lightning Web Component that makes calls to an Apex controller. Which THREE best practices should be followed when designing the Apex methods for LWC consumption? (Choose THREE)

Select 3 answers
A.Use primitive data types or simple serializable wrapper classes for parameters and return values.
B.Ensure Apex methods enforce object and field-level security (FLS) where appropriate.
C.Mark all Apex controller methods as global to allow unrestricted LWC access.
D.Annotate read-only methods with @AuraEnabled(cacheable=true) to improve performance.
E.Pass entire sobject records with complex parent relationships directly from client-side JavaScript without validation.
AnswersA, B, D

Lightning Web Components and Apex exchange data via JSON serialisation across the Lightning component framework boundary. Using primitive data types or simple serializable wrapper classes ensures that payloads seamlessly serialize and deserialize into standard JavaScript objects and types without requiring complex object mapping. This satisfies the architectural constraint for efficient data interchange between client-side JavaScript controllers and server-side Apex methods, preventing serialization failures and reducing the overhead associated with deeply nested or non-serializable complex objects.

Why this answer

Option A is correct because Apex methods exposed to Lightning Web Components via @AuraEnabled must use primitive types or simple serializable wrapper classes for parameters and return values, since complex or non-serializable types cannot be properly marshalled across the client-server boundary. Option B is correct because Apex does not automatically enforce object and field-level security (FLS) for @AuraEnabled methods, so developers must explicitly enforce CRUD/FLS using WITH SECURITY_ENFORCED, Security.stripInaccessible, or Schema describe calls to prevent unauthorized data exposure. Option D is correct because annotating read-only methods with @AuraEnabled(cacheable=true) enables client-side caching in the Lightning Data Service, reduces server round trips, and improves component performance for idempotent data retrieval.

Option C is incorrect because marking methods as global is unnecessary and overly permissive; @AuraEnabled methods only need to be public (or global in specific managed-package contexts) and global does not grant unrestricted LWC access. Option E is incorrect because passing entire sObjects with complex parent relationships without validation risks serialization failures, exceeds payload limits, and bypasses security and data integrity checks.

Exam trap

Salesforce-PD1 often tests the misconception that Apex automatically enforces FLS and sharing, when in fact developers must explicitly enforce security in @AuraEnabled methods.

45
MCQmedium

A developer is building a Lightning Web Component and needs to navigate to a URL that is external to Salesforce. Which PageReference type should be used with NavigationMixin?

A.standard__recordPage
B.standard__webPage
C.standard__namedPage
D.standard__objectPage
AnswerB

The `standard__webPage` PageReference type specifically satisfies the requirement to navigate to a URL that is external to Salesforce by accepting an external web address through its `type` and `attributes.url` properties. When implemented within the `NavigationMixin` API inside a Lightning Web Component, this configuration instructs the Lightning Experience navigation service to securely break out of the Salesforce domain and redirect the user's browser to the designated external endpoint, unlike internal page reference types restricted to internal Salesforce record views or standard object pages.

Why this answer

standard__webPage is the PageReference type for navigating to external URLs or web pages.

46
Multi-Selecteasy

Which TWO lifecycle hooks are available in Lightning Web Components? Choose 2 answers.

Select 2 answers
A.renderedCallback
B.init
C.connectedCallback
D.componentDidMount
E.willMount
AnswersA, C

`renderedCallback()` executes every time a component finishes rendering its HTML template, satisfying one of the two lifecycle hooks required by the question stem. This hook is unique to Lightning Web Components because it runs after every render phase, allowing developers to perform post-render logic, manipulate the DOM, or interact with child components after the template has been inserted into the document.

Why this answer

Option A, renderedCallback, is correct because it is a genuine Lightning Web Components lifecycle hook that fires after every render of a component, allowing you to perform logic that depends on the DOM being updated. Option C, connectedCallback, is also correct because it is a standard LWC lifecycle hook invoked when the component is inserted into the DOM, commonly used for initialization such as wiring up data or adding event listeners. The other options do not belong: init, componentDidMount, and willMount are lifecycle hooks from other frameworks or Aura/Lightning Aura terminology, not valid LWC lifecycle hooks.

Exam trap

The trap is cross-framework confusion — candidates who have React experience see 'componentDidMount' and 'willMount' and assume they exist in LWC, but LWC uses a completely different lifecycle model.

47
MCQmedium

A developer is building a Lightning Web Component and needs to perform validation on an input field before submission. Which method on a lighting-input element checks validity?

A.verify()
B.checkValidity()
C.isValid()
D.validate()
AnswerB

The `checkValidity()` method directly satisfies the validation constraint in the stem by programmatically evaluating the validity state of a `lightning-input` component. When invoked, it returns a boolean value indicating whether the field satisfies all built-in HTML5 and Salesforce constraint validations, such as required status, pattern matching, or minimum and maximum value limits. This enables developers to run pre-submission checks and halt the submission process if invalid data is detected.

Why this answer

lightning-input exposes a checkValidity() method that returns true if the input satisfies all its constraints (required, minlength, pattern, type-specific validation) and false otherwise, while also firing an invalid event and setting the validity property. It mirrors the native HTMLInputElement.checkValidity() API, which the base component wraps.

Exam trap

The trap is guessing at a method name that sounds semantically right (isValid, validate) instead of recalling that lightning-input deliberately mirrors the native HTML Constraint Validation API with checkValidity() and reportValidity().

How to eliminate wrong answers

Option A is wrong because verify() is not a method on lightning-input — it does not exist in the base component's API. Option C is wrong because isValid() is not a lightning-input method; validity state is exposed via the validity property and checked with checkValidity(), not a boolean getter named isValid(). Option D is wrong because validate() is not part of the lightning-input API — developers sometimes confuse it with custom validation patterns or Apex validation methods, but the base component uses checkValidity() and reportValidity().

48
Multi-Selecthard

Which THREE statements are true regarding Lightning Web Component shadow DOM encapsulation? Choose 3 answers.

Select 3 answers
A.Global CSS stylesheets automatically penetrate and override LWC shadow DOM styles.
B.Child components can be styled directly from parent CSS files without styling hooks.
C.querySelector calls inside a component only search within that component's template unless using specific host selectors.
D.Styles defined in a component's stylesheet only apply to that component.
E.HTML templates are rendered inside a shadow root for the component.
AnswersC, D, E

Shadow DOM scopes querySelector to the component's own template, so a component cannot reach into child components' internals. This satisfies the encapsulation constraint by preventing cross-boundary DOM access; traversing outward requires explicit host selectors such as this.template.host or :host, keeping each component's markup isolated.

Why this answer

Option C is correct because Lightning Web Components use native shadow DOM encapsulation, so a component's querySelector/querySelectorAll only traverse that component's own shadow root (its template), and reaching into a child component requires piercing selectors or the child's exposed API rather than ordinary descendant selectors. Option D is correct because each LWC's CSS file is scoped to that component's shadow root, so its rules apply only to elements within that component and do not leak out to the rest of the page. Option E is correct because LWC renders each component's template into a shadow root attached to the component's host element, which is the mechanism that provides the style and DOM encapsulation.

Option A is not correct because global stylesheets do not automatically penetrate shadow DOM; they only affect the host element or content explicitly exposed, and styling internals requires styling hooks or ::part. Option B is not correct because a parent cannot directly style a child component's internal elements from its own CSS file; cross-component styling must go through styling hooks (--slds-* custom properties) or exposed parts.

Exam trap

The trap is assuming shadow DOM is 'leaky' — candidates often think global CSS or parent styles can reach into child components, but LWC's encapsulation is strict and requires explicit styling hooks or ::part selectors.

49
MCQhard

A developer is writing a Lightning Web Component and needs to load a third-party JavaScript library (such as D3.js) stored as a static resource. Which lifecycle hook is most appropriate for initiating the load using loadScript?

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

connectedCallback() fires when the component is inserted into the DOM, making it the appropriate point to initiate loadScript for a static resource. Loading there ensures the third-party library, such as D3.js, is available before rendering logic that depends on it executes.

Why this answer

Third-party scripts should be loaded in connectedCallback() because the component must be inserted in the DOM before script tags can be appended.

50
MCQeasy

Which base component should be used in LWC to display a tabular grid of data with sorting and row selection?

A.lightning-datatable
B.lightning-grid
C.lightning-table
D.apex:pageBlockTable
AnswerA

`lightning-datatable` directly satisfies the requirement for a tabular grid with sorting and row selection by providing built-in attributes and columns definitions designed specifically for structured data display. It handles complex interactions like column-level sorting events and single or multi-row selection out of the box, whereas alternative components like `lightning-card` or custom HTML tables would require manual event handling and extensive state management to achieve the same functionality.

Why this answer

lightning-datatable is the correct base component for displaying tabular data with built-in support for sorting, row selection, and other features like inline editing. It is designed specifically for LWC and provides a rich set of attributes and events to handle data grid functionality.

Exam trap

SALESFORCE-PD1 often tests knowledge of LWC base components, and candidates may confuse lightning-datatable with non-existent components like lightning-grid or legacy Aura components like apex:pageBlockTable.

How to eliminate wrong answers

Option B is wrong because lightning-grid is not a standard base component in LWC; it does not exist. Option C is wrong because lightning-table is not a standard base component; the correct one is lightning-datatable. Option D is wrong because apex:pageBlockTable is an Aura component used in Visualforce pages, not an LWC base component.

51
MCQmedium

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

A.renderedCallback()
B.disconnectedCallback()
C.constructor()
D.connectedCallback()
AnswerD

`connectedCallback()` executes automatically the exact moment a component instance is inserted into the DOM, directly satisfying the requirement to run initialisation logic at that specific stage. This hook fires before rendering completes, making it the appropriate location for setting up initial data states, adding event listeners, or performing API calls that prepare the component for interaction. Relying on this standard web component lifecycle method ensures your custom initialisation routines align with the underlying DOM insertion sequence.

Why this answer

connectedCallback() is invoked when a component is inserted into the DOM, making it the standard hook for initialization logic.

52
MCQhard

A developer is building a Lightning Web Component and needs to listen to a custom event dispatched by a child component. How is the event listener attached in the parent HTML template?

A.onmyevent={handler}
B.event-myevent={handler}
C.on-myevent={handler}
D.listener={handler}
AnswerA

Lightning Web Components use standard HTML event syntax where custom events dispatched from a child component are listened for in the parent template by prefixing the event name with "on" in lower camel case. To satisfy the requirement of listening to a custom event dispatched by a child component, appending the prefix directly to the event type—such as `onmyevent={handler}`—automatically binds the designated JavaScript handler method to the declarative template without requiring imperative DOM manipulation.

Why this answer

Child events are listened to using on<eventname> attribute syntax in the parent template.

53
MCQhard

A developer is building a Lightning Web Component that includes a custom wire adapter to fetch custom metadata. The wire adapter needs to react whenever a tracked property changes value. How should the developer wire the property?

A.Prefix the parameter passed to the wire adapter with a dollar sign ($) in the JavaScript file.
B.Wrap the property in a standard JavaScript Proxy object.
C.Decorate the parameter with @track and call this.updateWire() explicitly.
D.Invoke the refreshApex() method inside the component constructor.
AnswerA

Prefixing a property with a dollar sign in a Lightning Web Component JavaScript file enables reactive property binding for wire adapters. This mechanism directly satisfies the requirement for the wire adapter to react whenever a tracked property changes value. By prepending the `$` symbol, the Lightning framework marks the variable as reactive, ensuring that the custom wire adapter automatically provisions new data and re-runs whenever the underlying property's value updates.

Why this answer

In LWC, wire adapters are reactive when their parameters are prefixed with '$' in the JavaScript file, which tells the framework to re-invoke the adapter whenever the referenced property changes. For a custom wire adapter that fetches custom metadata, the developer writes something like @wire(getCustomMetadata, { recordId: '$recordId' }) so that changes to recordId automatically re-fire the adapter.

Exam trap

Salesforce-PD1 often tests the '$' prefix syntax for reactive wire parameters — the trap is choosing @track or refreshApex(), which are for different reactivity scenarios (template rendering and manual Apex refresh, respectively).

How to eliminate wrong answers

Option B is wrong because wrapping a property in a JavaScript Proxy is a general reactivity technique, not the LWC wire mechanism — LWC uses its own reactive proxy internally, and developers do not wrap wire parameters manually. Option C is wrong because @track is for making object/array fields reactive for template rendering, and there is no this.updateWire() API in LWC — wire adapters refresh automatically when their reactive parameters change. Option D is wrong because refreshApex() is used to manually refresh an @wire result from an Apex method, not to make a custom adapter reactive, and it cannot be called in the constructor before the wire has provisioned.

54
MCQmedium

A developer needs to retrieve Salesforce data in a Lightning Web Component without writing imperative Apex. Which module should be imported to use the wire service for standard record data?

A.lightning/platformShowErrorToast
B.lightning/navigation
C.lightning/uiRecordApi
D.lightning/apex
AnswerC

`lightning/uiRecordApi` provides built-in wire adapters such as `getRecord`, which directly satisfies the requirement to retrieve standard record data without writing imperative Apex. By importing this standard module, a Lightning Web Component can declaratively access, read, and manipulate Salesforce record data via the Lightning Data Service architecture. This avoids the need for server-side controller methods, streamlining data retrieval while automatically managing caching, error handling, and UI synchronisation in compliance with the specified constraint.

Why this answer

lightning/uiRecordApi provides wire adapters to get, create, update, or delete record data.

55
MCQhard

A developer creates a Lightning Web Component that includes a third-party JavaScript library loaded via a Static Resource. In which lifecycle hook should the third-party library be initialized?

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

`connectedCallback` fires when the element is inserted into the DOM, giving the earliest point at which the statically loaded library is available and the component's DOM exists. Initialising here satisfies the scenario's requirement to set up the third-party library before rendering completes, rather than deferring to `renderedCallback`, which may run multiple times.

Why this answer

The connectedCallback lifecycle hook fires when a component is inserted into the DOM, making it the correct place to initialize third-party libraries that need a DOM element to attach to. At this point, the component's template elements exist and the library can be safely instantiated.

Exam trap

Salesforce PD1 often tests confusion between connectedCallback and renderedCallback, tricking candidates into picking renderedCallback for one-time initialization when it actually fires repeatedly.

How to eliminate wrong answers

Option A is wrong because disconnectedCallback fires when the component is removed from the DOM — initializing a library there makes no sense and would run at the wrong time. Option C is wrong because renderedCallback fires after every render and can run multiple times, causing the library to be re-initialized repeatedly unless guarded, leading to memory leaks and duplicate event handlers. Option D is wrong because the constructor runs before the component is connected to the DOM; the template elements don't exist yet, so a library requiring DOM access would fail.

56
MCQmedium

A developer is building a Visualforce page that uses a custom controller and needs to display a message to the user when an error occurs. Which class and method should be used?

A.ApexPages.currentPage().getParameters().put()
B.ApexPages.addMessage()
C.Database.addError()
D.System.debug()
AnswerB

`ApexPages.addMessage()` provides the correct mechanism to satisfy the requirement of displaying an error message to the user within a custom controller. By instantiating an `ApexPages.Message` object—specifying the severity level, such as `ApexPages.Severity.ERROR`—and passing it to the `ApexPages.addMessage()` method, the developer queues the message for display. This directly integrates with Visualforce components like `<apex:pageMessages />`, rendering the alert correctly on the page without needing to navigate away or rely on standard controller context.

Why this answer

ApexPages.addMessage() adds an ApexPages.Message to the page messages list.

57
MCQmedium

A developer is implementing a Lightning Web Component with a custom CSS file. How does the component load its associated stylesheet?

A.By declaring the stylesheet in the component's js-meta.xml configuration file.
B.By importing the CSS file explicitly at the top of the JavaScript file using an import statement.
C.Automatically by sharing the exact base file name in the same component bundle folder.
D.Using a <link rel="stylesheet"> tag inside the component HTML template.
AnswerC

Lightning Web Components leverage shadow DOM encapsulation, which automatically discovers and applies a CSS file if it shares the exact base name as the JavaScript and HTML files within the same component bundle folder. This convention-based loading mechanism satisfies the requirement to associate a custom stylesheet without needing explicit import statements or static resource references, relying entirely on the Salesforce platform's standard build system to bundle and inject the scoped styles directly into the component's template.

Why this answer

In a Lightning Web Component bundle, the CSS file is loaded automatically when it shares the exact base file name with the component and resides in the same bundle folder. For example, `myComponent.css` alongside `myComponent.js`, `myComponent.html`, and `myComponent.js-meta.xml` is applied automatically — no import or link tag is needed.

Exam trap

Salesforce PD1 often tests the misconception that CSS must be imported or linked explicitly, when LWC auto-loads it by matching the bundle's base file name.

How to eliminate wrong answers

Option A is wrong because the js-meta.xml file configures metadata (targets, API version, exposed properties), not stylesheet loading. Option B is wrong because LWC JavaScript does not support importing CSS files via import statements — that is a bundler pattern (e.g., webpack), not LWC. Option D is wrong because LWC templates do not support <link rel="stylesheet"> tags; styles are scoped and injected by the framework.

58
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 the developer use?

A.constructor()
B.disconnectedCallback()
C.renderedCallback()
D.connectedCallback()
AnswerD

`connectedCallback()` fires automatically the exact moment a component is inserted into the DOM, satisfying the requirement to execute code immediately upon DOM insertion. This standard browser lifecycle hook executes during the component's rendering phase before the template is fully evaluated, making it the appropriate mechanism for initialization tasks such as fetching initial data, registering event listeners, or setting up reactive properties required as soon as the element exists within the document object model hierarchy.

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 DOM, such as accessing elements or making network requests. It fires after the constructor but before rendering.

Exam trap

SALESFORCE-PD1 often tests lifecycle hooks, and candidates may confuse connectedCallback() with renderedCallback() or constructor(), especially regarding when the DOM is available.

How to eliminate wrong answers

Option A is wrong because constructor() is called when the component is created, before it is inserted into the DOM, and you cannot access the DOM or properties from the template there. Option B is wrong because disconnectedCallback() is called when the component is removed from the DOM, not inserted. Option C is wrong because renderedCallback() is called after the component's template has been rendered, which is after insertion, but it can fire multiple times and is not the first hook for DOM insertion.

59
MCQhard

A developer is implementing navigation in a Lightning Experience app using the NavigationMixin service in a Lightning Web Component. The developer wants to navigate to a standard ListView for the Account object. What is the correct type to specify?

A.type: 'standard__objectPage', attributes: { objectApiName: 'Account', actionName: 'list' }
B.type: 'standard__webPage', attributes: { url: '/lightning/o/Account/list' }
C.type: 'standard__recordPage', attributes: { objectApiName: 'Account', actionName: 'view' }
D.type: 'standard__namedPage', attributes: { pageName: 'accountList' }
AnswerA

Navigating to a standard ListView for the Account object within a Lightning Web Component requires the `standard__objectPage` page reference type, which directly satisfies the requirement to target a specific object's context rather than a generic page or record. By supplying the `objectApiName` attribute as 'Account' alongside the `actionName` attribute set to 'list', the NavigationMixin service correctly resolves the request to render the tabular list view for that specific sObject without requiring hardcoded URLs.

Why this answer

NavigationMixin.Navigate uses standard page references where type is 'standard__objectPage' and actionName is 'list'.

60
MCQhard

A developer is troubleshooting a Lightning Web Component where data returned from an Apex wire adapter needs to be mutated before being rendered. What is the correct pattern to handle this?

A.Decorate the wire property with @api mutable to allow direct writes.
B.Use the eval() function to strip immutability constraints from the prototype chain.
C.Create a shallow copy or clone of the wire data object in a getter or property assignment before mutation.
D.Directly assign new properties to the object returned by the wire adapter property.
AnswerC

Wire adapter data is read-only and frozen, so direct mutation throws in strict mode. Cloning via spread or structuredClone in a getter or property assignment produces a mutable copy, satisfying the stem's need to transform Apex-returned data before rendering without breaking reactivity.

Why this answer

Data returned from an Apex wire adapter is immutable (read-only). To mutate it, you must create a shallow copy or clone of the object before making changes. This can be done in a getter or by assigning the copied data to a new property.

This pattern ensures you do not attempt to modify the original wire data, which would cause an error.

Exam trap

The trap is assuming that wire data can be directly mutated, or that decorators like @api can make it mutable; candidates may overlook the immutability constraint.

How to eliminate wrong answers

Option A is wrong because @api mutable is not a valid decorator; @api is used to expose public properties, but it does not make wire data mutable. Option B is wrong because using eval() to strip immutability is a hack and not recommended; it can lead to security issues and is not a supported pattern. Option D is wrong because directly assigning new properties to the wire data object will fail silently or throw an error in strict mode, as the object is frozen.

61
MCQeasy

What is the correct file extension for a Lightning Web Component HTML template file?

A..vfp
B..page
C..html
D..cmp
AnswerC

Lightning Web Components strictly mandate that the user interface template file must use the standard `.html` file extension, perfectly fulfilling the exact file naming constraint specified in the stem. The Salesforce platform parser relies on this precise suffix to automatically identify, compile, and bundle the markup file alongside the corresponding JavaScript controller and configuration metadata within the component's bundle structure.

Why this answer

LWC HTML template files must use the .html extension and share the component base name.

62
MCQhard

A developer is configuring a Lightning Web Component that uses the Lightning Message Service (LMS). Which module must be imported to publish a message on a message channel?

A.lightning/uiRecordApi
B.lightning/empApi
C.lightning/navigation
D.lightning/messageService
AnswerD

Publishing a message on a message channel via the Lightning Message Service requires importing the `publish` function from the `lightning/messageService` module. This specific module provides the fundamental messaging primitives necessary for communication across the DOM, directly satisfying the requirement to trigger outbound messages within a Lightning Web Component. Without importing this exact module, developers cannot access the runtime context needed to broadcast payloads across the Salesforce application architecture.

Why this answer

publish function and the message channel reference are imported from lightning/messageService and the channel definition file respectively.

63
MCQmedium

A developer is writing a Visualforce page with custom controller logic and needs to ensure that database operations are executed transactionally. What happens by default when an unhandled exception occurs during a controller action method?

A.The entire transaction is rolled back.
B.The user is redirected to the login page.
C.Only partial records are saved; successful ones are committed.
D.Changes are committed and an email is sent to the admin.
AnswerA

Visualforce controller action methods inherently execute within a standard database transaction context that satisfies the requirement for transactional integrity. When an unhandled exception halts execution, the Salesforce platform automatically triggers a complete rollback of any database DML operations performed up to that point. This atomic mechanism prevents partial data commits, ensuring that no corrupted or incomplete records persist in the database, thereby fulfilling the explicit need for safe, all-or-nothing execution during custom controller logic.

Why this answer

In Visualforce with a custom controller, an unhandled exception during a controller action method causes the entire transaction to roll back by default. Salesforce wraps the request in a database transaction, so any DML performed before the exception is undone, preserving atomicity.

Exam trap

Salesforce-PD1 often tests the misconception that partial DML commits on exception, when in fact the default behavior is full transaction rollback unless the exception is caught.

How to eliminate wrong answers

Option B is wrong because an unhandled exception produces an error page, not a login redirect; authentication failures cause redirects, not controller exceptions. Option C is wrong because Salesforce does not partially commit — the transaction is atomic, so successful DML before the exception is rolled back. Option D is wrong because changes are not committed on exception, and no admin email is automatically sent for controller exceptions.

64
MCQmedium

A developer has a Lightning Web Component with a reactive property 'recordId'. How should the property be decorated to ensure it receives the current record ID when placed on a record page?

A.@wire recordId;
B.@track recordId;
C.@wire(getRecord) recordId;
D.@api recordId;
AnswerD

Decorating the `recordId` property with the `@api` decorator exposes it as a public property, satisfying the requirement to dynamically receive context from the hosting Lightning record page. When placed on a record page, the Salesforce framework automatically injects the current record's ID into this reactive property, enabling the component to initialise data fetching or perform record-specific logic without requiring manual configuration by the administrator.

Why this answer

The @api decorator makes a property public and reactive, allowing a parent component or the Lightning record page to pass the recordId into the component. On a record page, the framework automatically injects the current record ID into any public property named recordId. Without @api, the property is private and will not receive the value.

Exam trap

Salesforce-PD1 often tests the confusion between @api (public property for parent-to-child and record page injection) and @wire (data binding to Apex or UI API adapters).

How to eliminate wrong answers

Option A is wrong because @wire is used to wire a property or function to an Apex method or a UI API adapter, not to expose a property for parent-to-child communication. Option B is wrong because @track is used for making private fields reactive for internal changes; it does not make the property public or receive values from the record page. Option C is wrong because @wire(getRecord) is a specific adapter call to fetch record data, not a decorator for receiving the recordId; it also requires additional parameters and does not simply expose the ID.

65
MCQeasy

A developer wants to include a custom styling hook to override a standard Lightning Design System component token in a Lightning Web Component. Where should this CSS custom property be defined?

A.Inside the component controller JavaScript file (.js)
B.In the component's cascading style sheet file (.css)
C.In a separate Static Resource uploaded to Salesforce
D.In the component's configuration file (.js-meta.xml)
AnswerB

Defining the custom property directly within the component's cascading style sheet file (`.css`) satisfies the requirement to scope the SLDS component token override specifically to that Lightning Web Component. Salesforce requires component-level styling hooks to be declared in the local stylesheet so that the Shadow DOM encapsulation correctly applies the scoped custom property (`--slds-...`) to override the standard token values without unintentionally bleeding styles into other DOM elements on the page.

Why this answer

Lightning Web Components use standard CSS custom properties (design tokens) to allow styling overrides, and these must be defined in the component's .css file. The CSS file is where SLDS styling hooks are declared, scoped to the component's shadow DOM, so the override applies only to that component.

Exam trap

The trap is assuming styling hooks can be set in JS or metadata files — candidates who are unfamiliar with shadow DOM scoping often pick the JS file, but CSS custom properties must live in the .css file.

How to eliminate wrong answers

Option A is wrong because JavaScript files cannot define CSS custom properties — styling is not a JS concern, and the LWC framework does not read style tokens from JS. Option C is wrong because Static Resources are for uploading files like images or third-party libraries, not for defining component-scoped CSS tokens; they cannot be applied as live styles to a component's shadow DOM. Option D is wrong because the .js-meta.xml file configures component metadata (targets, API version, exposed properties), not styling — CSS custom properties have no place there.

66
Multi-Selectmedium

Which TWO techniques can be used to pass data from a parent component to a child Lightning Web Component? Choose 2 answers.

Select 2 answers
A.Using application events via $A.get('e...')
B.Calling public @api methods defined on the child component instance from the parent JavaScript.
C.Directly modifying child private properties using DOM queries.
D.Using global window variables.
E.Binding properties to public @api properties on the child component in the parent template.
AnswersB, E

Exposing methods with the `@api` decorator on the child component allows the parent component to invoke them directly via the child's DOM element reference. This satisfies the requirement to pass data downwards from parent to child because the parent's JavaScript controller can supply parameters when calling the public method, effectively pushing data and triggering behaviour within the child context upon demand.

Why this answer

Data is passed down via public properties decorated with @api or by invoking public child methods.

67
MCQhard

A developer creates a Lightning Web Component that consumes data from a wire adapter. The wire adapter returns an object with 'data' and 'error' properties. What is this pattern called in LWC?

A.Event emitter pattern
B.Promise chaining
C.Async/await callback pattern
D.Wired property / result object pattern
AnswerD

Consuming data via a wire adapter that returns an object containing both `data` and `error` properties explicitly satisfies the wired property or result object pattern in Lightning Web Components. When a wire adapter is provisioned as a property rather than a function, Salesforce delivers an immutable result object encapsulating these two distinct states. This architecture allows developers to declaratively handle both successful payload retrieval and exception states seamlessly within the component lifecycle without manually invoking imperative Apex or managing asynchronous promises.

Why this answer

Wire adapters return a wrapper object containing data and error properties.

68
MCQeasy

A developer is building a Lightning Web Component that must be made available for use on Lightning Record Pages. Which configuration tag must be included in the component's metadata file?

A.lightning__UtilityBar
B.lightning__GlobalAction
C.lightning__RecordPage
D.lightning__AppPage
AnswerC

The `lightning__RecordPage` target in the metadata file exposes the component for placement on Lightning Record Pages, satisfying the stem's requirement. Other targets, such as `lightning__AppPage` or `lightning__HomePage`, permit different page types only. Without this specific target declared, the component cannot be added to record pages.

Why this answer

To expose an LWC on a Lightning Record Page, the component's .js-meta.xml file must include the <target>lightning__RecordPage</target> tag. This target tells the platform that the component is eligible to be dragged onto record pages in Lightning App Builder, and it is the specific configuration required for record-page availability.

Exam trap

Salesforce PD1 often tests the exact target name for a given surface; candidates confuse lightning__RecordPage with lightning__AppPage or lightning__HomePage because all are 'page' targets but apply to different contexts.

How to eliminate wrong answers

Option A is wrong because lightning__UtilityBar targets the utility bar (a persistent footer bar for tools like notes and recent items), not record pages. Option B is wrong because lightning__GlobalAction exposes the component as a global quick action, not as a record page component. Option D is wrong because lightning__AppPage targets a custom Lightning app page (a standalone page in the app), not a record page tied to an object record.

69
MCQhard

A developer needs to catch unhandled JavaScript errors in a Lightning Web Component hierarchy so the entire app doesn't crash. Which lifecycle hook handles errors thrown by descendant components?

A.errorCallback
B.catchCallback
C.disconnectedCallback
D.faultCallback
AnswerA

The `errorCallback()` lifecycle hook acts as an error boundary for a Lightning Web Component, directly satisfying the requirement to catch unhandled errors thrown by descendant components in the hierarchy. When a child component throws an error during rendering, in a lifecycle hook, or in an event handler, the framework automatically invokes this method on the nearest ancestor implementing it, receiving the error object and stack trace. This containment prevents the entire application from crashing and allows developers to render an alternative user interface.

Why this answer

errorCallback() is invoked when a descendant component throws an error in any of its lifecycle hooks or event handlers.

70
Multi-Selecthard

Which THREE requirements must be met when implementing a custom Lightning Web Component pagination control? Choose 3 answers.

Select 3 answers
A.Slice the master dataset array based on current offset and limit calculations.
B.Use standard Visualforce standardSetController inside the LWC JavaScript.
C.Disable navigation buttons (Next/Previous) when boundary conditions are reached.
D.Maintain reactive properties for the current page number and page size.
E.Directly mutate the server database on every page click.
AnswersA, C, D

Pagination in a custom Lightning Web Component requires manual data slicing to manage large collections efficiently within the client-side JavaScript controller. Because Salesforce sets strict performance boundaries and DOM rendering limits for browser-based components, loading an entire master dataset simultaneously degrades user experience. Calculating precise array slices using dynamic offset and limit variables ensures that only the subset of records currently visible on the active page is rendered in the DOM, satisfying the fundamental performance and data-handling requirements of a custom pagination control.

Why this answer

Option A is correct because a custom LWC pagination control must compute the visible subset of records by slicing the master dataset array using the current offset (page number × page size) and the page size limit, since LWC has no built-in pagination primitive. Option C is correct because the Next and Previous buttons must be disabled when boundary conditions are reached — Previous at page 1 and Next at the last page — to prevent out-of-range navigation and provide correct UX. Option D is correct because the component must track the current page number and page size as reactive properties (e.g., @track or standard reactive fields) so that changes trigger re-rendering and recomputation of the sliced data.

Option B is incorrect because Visualforce's standardSetController is a Visualforce/Apex construct and cannot be used inside LWC JavaScript; pagination in LWC is handled client-side or via Apex methods. Option E is incorrect because mutating the server database on every page click is unnecessary and harmful — pagination should only change the client-side view, not persist data on each navigation.

Exam trap

Salesforce PD1 often tests the misconception that Visualforce controllers (standardSetController) can be reused in LWC, or that pagination requires server-side mutation on every click.

71
Multi-Selectmedium

Which TWO actions should a developer take when handling errors returned by an imperative Apex call in a Lightning Web Component? Choose 2 answers.

Select 2 answers
A.Call ApexPages.addMessage() to display the error on screen.
B.Extract the error message from the error object structure (e.g., error.body.message).
C.Rethrow the error as an unhandled Java exception.
D.Catch the error using a .catch() block or try/catch with async/await.
E.Use standard window.alert() for all error messaging.
AnswersB, D

Imperative Apex calls in Lightning Web Components return errors as JavaScript objects whose structure typically places the main description within the `error.body.message` property. Accessing this nested path directly satisfies the requirement to safely extract and display failure details returned from the server. Relying on this standard Lightning Data Service and imperative error structure ensures developers can reliably parse backend exceptions and present meaningful feedback to the user interface.

Why this answer

Option B is correct because when an imperative Apex call fails, the promise rejects with a JavaScript error object whose useful details live in nested properties such as error.body.message (and error.body.pageErrors or error.body.fieldErrors), so the developer must extract the message from that structure to surface a meaningful error. Option D is correct because imperative Apex calls return a Promise, so errors must be handled by chaining a .catch() handler or by wrapping the call in try/catch when using async/await; otherwise the rejection is unhandled. Option A is wrong because ApexPages.addMessage() is a server-side Apex method for Visualforce pages, not for Lightning Web Components.

Option C is wrong because Apex is not Java and rethrowing as an unhandled Java exception is neither possible nor a valid LWC error-handling pattern. Option E is wrong because window.alert() is a blocking browser dialog and is not the recommended way to present errors in a Lightning Web Component, which should use lightning-toast or inline UI instead.

Exam trap

Salesforce PD1 often tests the confusion between Visualforce error handling (ApexPages.addMessage) and LWC error handling, and candidates may incorrectly assume that errors are automatically displayed or that alert is acceptable.

72
MCQmedium

A developer is creating a reusable LWC utility and needs to invoke an Apex method imperatively. The method accepts a record ID parameter. What is the correct way to pass this parameter in JavaScript?

A.Pass the parameter as an object with property names matching the Apex method parameters: getAccount({ accountId: recordId })
B.Pass the parameter as a positional string argument: getAccount({recordId})
C.Bind the parameter using the @api decorator inside the JavaScript function body.
D.Assign the parameter to the window.apexParams object prior to invocation.
AnswerA

Imperative Apex method calls in Lightning Web Components require parameters to be structured as an object where the property names explicitly match the parameter definitions expected by the Apex controller. This exact syntax satisfies the requirement to invoke the method while passing a record ID parameter, ensuring the JavaScript wire adapter or imperative promise correctly serialises and maps the arguments to the backend method signature.

Why this answer

When invoking an Apex method imperatively from LWC, parameters must be passed as a single object where the keys match the Apex method parameter names exactly. For an Apex method like getAccount(Id accountId), the JavaScript call should be getAccount({ accountId: recordId }). This ensures the correct mapping of values to parameters.

Exam trap

SALESFORCE-PD1 often tests the correct syntax for imperative Apex calls, and candidates may mistakenly pass parameters as positional arguments or use incorrect object keys.

How to eliminate wrong answers

Option B is wrong because passing a positional argument like {recordId} does not match the Apex parameter name 'accountId', and the object key must match the Apex parameter name. Option C is wrong because the @api decorator is used to expose properties or methods from a component, not to bind parameters for Apex calls. Option D is wrong because there is no window.apexParams object; parameters are passed directly in the imperative call.

73
MCQhard

A developer is writing a custom wire adapter or working with custom data in LWC and needs to manually provision data or force a refresh of wire data. Which function should be imported from lightning/uiRecordApi or related wire modules?

A.reloadRecord
B.updateRecordCache
C.getRecordRefresh
D.refreshApex
AnswerD

`refreshApex` is the correct function to import because it imperatively provisions data and forces a refresh of cached wire data by invalidating the cache for a specific Apex method promise. This directly satisfies the requirement to manually provision data or force a refresh when working with custom data adapters or Apex-based wire services in Lightning Web Components, where standard record-level mutation functions from `lightning/uiRecordApi` are inapplicable.

Why this answer

refreshApex is used to imperatively refresh data provisioned by an Apex wire adapter.

74
Multi-Selectmedium

A developer is designing a Lightning Web Component that needs to be conditionally displayed in different Salesforce containers. Which TWO targets are valid entries in the component's js-meta.xml configuration file? (Choose TWO)

Select 2 answers
A.lightning__CustomField
B.lightning__HomePage
C.lightning__ApprovalProcess
D.lightning__ApexClass
E.lightning__RecordPage
AnswersB, E

Enabling a component to appear on a home page container directly satisfies the requirement for conditional display across different Salesforce locations. The `lightning__HomePage` target explicitly grants permission for the Lightning Web Component to be added specifically to home pages via the Lightning App Builder, fulfilling one of the necessary container placement options specified in the stem while adhering to the metadata configuration schema.

Why this answer

Option B, lightning__HomePage, is a valid target because it allows the Lightning Web Component to be exposed on the Home page in Lightning Experience, which is one of the supported containers for conditional display. Option E, lightning__RecordPage, is also valid because it lets the component be placed on record pages, another standard Lightning Experience container. The other options are not valid targets: lightning__CustomField, lightning__ApprovalProcess, and lightning__ApexClass are not recognized js-meta.xml targets for exposing an LWC in a Salesforce container.

Therefore, only B and E are correct.

Exam trap

Salesforce PD1 often tests the distinction between valid and invalid LWC targets, and candidates may confuse targets with other metadata types like custom fields or Apex classes.

75
MCQmedium

A developer is creating a Lightning Web Component and needs to iterate over a list of items in the HTML template. Which directive should be used?

A.repeat:for
B.for:each
C.apex:repeat
D.aura:iteration
AnswerB

The `for:each` directive satisfies the requirement to iterate over a list of items directly within a Lightning Web Component HTML template. When combined with the `for:item` directive and a unique `key` attribute on the rendered elements, it maps each item in the JavaScript array to the DOM. This declarative syntax provides the native mechanism needed to render repetitive structures efficiently without requiring imperative JavaScript manipulation.

Why this answer

LWC templates use the for:each directive to iterate over arrays, with for:item specifying the iteration variable and for:index providing the optional index. Each iterated element must have a unique key attribute (typically the record Id) to help the framework's diffing algorithm efficiently update the DOM.

Exam trap

The trap is mixing up iteration syntax across Salesforce frameworks — candidates who have written Visualforce or Aura code often select apex:repeat or aura:iteration out of habit, forgetting that LWC uses the distinct for:each directive.

How to eliminate wrong answers

Option A is wrong because repeat:for is not a valid LWC directive — the syntax is for:each, and there is no repeat:for construct in LWC templates. Option C is wrong because apex:repeat is a Visualforce iteration component, not usable in LWC templates. Option D is wrong because aura:iteration is the Aura component iteration tag, which belongs to the older Aura framework, not LWC.

Page 1 of 2 · 91 questions totalNext →

Ready to test yourself?

Try a timed practice session using only User Interface questions.