Praxis Academy
Home › Platform Developer › User Interface

Platform Developer practice questions: User Interface

User Interface is 25% of the Salesforce Certified Platform Developer exam. It covers Lightning Web Components, Aura, Visualforce and Apex controllers. Try these 20 free questions, then open each answer to see why every option is right or wrong.

01

Which three files in an Aura component bundle can contain JavaScript that defines the component's client-side behavior? Choose 3 answers.

Choose three.

  1. Client-side controller
  2. Helper
  3. Design file
  4. Renderer
  5. CSS style file
Show answer

Answer: A, B, D

A. Client-side controller ✓Correct. The controller holds action handlers for component events.
B. Helper ✓Correct. The helper holds reusable JavaScript functions called from the controller or renderer.
C. Design fileThe design file defines attributes exposed in Lightning App Builder; it contains no JavaScript.
D. Renderer ✓Correct. The renderer can override the default rendering behavior with JavaScript.
E. CSS style fileThe style file contains CSS only.

Why: In an Aura bundle, JavaScript lives in the controller, the helper, and the renderer. The design file is XML for App Builder settings, and the style file contains CSS.

02

A developer wants a Lightning web component to display a company logo, custom icons, and shared styling. Which three types of resources can the component reference directly? Choose 3 answers.

Choose three.

  1. Static resources, such as images, CSS files, or ZIP archives
  2. Canvas apps
  3. SVG files included in the component folder or imported as resources
  4. Content asset files
  5. Connected apps
Show answer

Answer: A, C, D

A. Static resources, such as images, CSS files, or ZIP archives ✓Correct. Static resources are imported with @salesforce/resourceUrl.
B. Canvas appsCanvas apps embed external applications; they are not resources a component imports.
C. SVG files included in the component folder or imported as resources ✓Correct. SVG graphics can be used as icons in a component.
D. Content asset files ✓Correct. Content asset files are imported with @salesforce/contentAssetUrl.
E. Connected appsConnected apps configure OAuth integrations and are not UI resources.

Why: LWC can import static resources with @salesforce/resourceUrl, content asset files with @salesforce/contentAssetUrl, and can use SVG graphics for icons.

03

In an online store built with Lightning web components, a child component has a Place Order button. When it is clicked, the parent component must be notified so it can show a confirmation. How should this be implemented?

  1. The child calls this.parent.handleOrder() directly.
  2. The child dispatches a CustomEvent with this.dispatchEvent(), and the parent listens with an on<eventname> handler in its template.
  3. The child publishes a Lightning Message Service message for the parent.
  4. The child sets an @api property on the parent.
Show answer

Answer: B

A. The child calls this.parent.handleOrder() directly.Components cannot call methods on their parent directly.
B. The child dispatches a CustomEvent with this.dispatchEvent(), and the parent listens with an on<eventname> handler in its template. ✓Correct. Dispatching a custom event is the standard child-to-parent pattern.
C. The child publishes a Lightning Message Service message for the parent.Lightning Message Service is for communication between components that are not in the same hierarchy.
D. The child sets an @api property on the parent.@api properties pass data from parent to child, not the other way around.

Why: In LWC, a child communicates with its parent by dispatching a custom event. The parent adds a handler with an on prefix to the child tag in its template, for example onorderplaced.

04

A developer built a Lightning web component called interactionTimeline and wants admins to add it to the Account record page in Lightning App Builder. Which two settings are required in the component's configuration file? Choose 2 answers.

Choose two.

  1. Set isExposed to true.
  2. Add a target with the value lightning__RecordPage.
  3. Add a target with the value lightning__HomePage.
  4. Add a masterLabel element with the value Account.
Show answer

Answer: A, B

A. Set isExposed to true. ✓Correct. isExposed must be true for the component to be available in App Builder.
B. Add a target with the value lightning__RecordPage. ✓Correct. lightning__RecordPage makes the component available on record pages.
C. Add a target with the value lightning__HomePage.lightning__HomePage makes it available on Home pages, not record pages.
D. Add a masterLabel element with the value Account.masterLabel only sets the display name; it does not make the component available.

Why: To appear in Lightning App Builder, a component must be exposed with isExposed set to true and must list the page types it supports in its targets, such as lightning__RecordPage.

05

A Visualforce page opened from a button on the Case page uses the Case standard controller. Its custom Save button must run complex validation across several objects and, if successful, send the user to a thank-you page. What should the developer use?

  1. A custom controller that extends the standard Controller class
  2. A controller extension with its own save() method that returns a PageReference
  3. A validation rule with cross-object formulas
  4. An after update trigger that redirects with setPageReference()
Show answer

Answer: B

A. A custom controller that extends the standard Controller classApex has no Controller base class to extend.
B. A controller extension with its own save() method that returns a PageReference ✓Correct. The extension keeps standard controller features and adds the custom save logic.
C. A validation rule with cross-object formulasValidation rules cannot redirect the user.
D. An after update trigger that redirects with setPageReference()Triggers cannot redirect users to another page.

Why: A controller extension adds or overrides actions on a standard controller. A custom save() method can run the validation and return a PageReference to redirect the user.

06

Which two are phases of event propagation for Aura component events? Choose 2 answers.

Choose two.

  1. Bubble, where the event moves up from the source component toward the root
  2. Default, where the framework runs default handling after the other phases
  3. Broadcast, where the event is sent to every component on the page at once
  4. Dispatch, where the event goes only to the target component
Show answer

Answer: A, B

A. Bubble, where the event moves up from the source component toward the root ✓Correct. The bubble phase moves the event up the containment hierarchy.
B. Default, where the framework runs default handling after the other phases ✓Correct. The default phase runs after the other phases unless the event is stopped.
C. Broadcast, where the event is sent to every component on the page at onceBroadcast is not a propagation phase.
D. Dispatch, where the event goes only to the target componentDispatch is not a propagation phase.

Why: Aura events propagate through capture and bubble phases, and application events also have a default phase. Broadcast and dispatch are not propagation phases.

07

A Lightning web component wires the property matches to an Apex method. Which Apex method definition supports @wire?

  1. @AuraEnabled(cacheable=false) public static List<Listing__c> findListings(String term)
  2. @AuraEnabled(cacheable=true) public static List<Listing__c> findListings(String term)
  3. @AuraEnabled(cacheable=true) public List<Listing__c> findListings(String term)
  4. @AuraEnabled(cacheable=false) public List<Listing__c> findListings(String term)
Show answer

Answer: B

A. @AuraEnabled(cacheable=false) public static List<Listing__c> findListings(String term)Wired methods must be cacheable.
B. @AuraEnabled(cacheable=true) public static List<Listing__c> findListings(String term) ✓Correct. It is static and cacheable.
C. @AuraEnabled(cacheable=true) public List<Listing__c> findListings(String term)@AuraEnabled methods must be static.
D. @AuraEnabled(cacheable=false) public List<Listing__c> findListings(String term)It is neither static nor cacheable.

Why: To be wired, an Apex method must be static and annotated with @AuraEnabled(cacheable=true). Cacheable methods cannot perform DML.

08

Users edit Product records in both Salesforce Classic and Lightning Experience. The company wants a custom screen to open when users click Edit, in either experience. How should the Edit button be overridden?

  1. A Lightning page in Classic and a Visualforce page in Lightning Experience
  2. A Visualforce page in Classic and a Lightning page in Lightning Experience
  3. A Visualforce page in Classic and a Lightning component in Lightning Experience
  4. A Lightning component in both Classic and Lightning Experience
Show answer

Answer: C

A. A Lightning page in Classic and a Visualforce page in Lightning ExperienceLightning pages cannot override buttons in Classic.
B. A Visualforce page in Classic and a Lightning page in Lightning ExperienceLightning pages are not used to override the Edit button.
C. A Visualforce page in Classic and a Lightning component in Lightning Experience ✓Correct. Visualforce for Classic and a Lightning component for Lightning Experience.
D. A Lightning component in both Classic and Lightning ExperienceLightning component overrides only apply in Lightning Experience and the mobile app.

Why: Standard buttons can be overridden with Visualforce pages in Classic and with Lightning components in Lightning Experience. Lightning components are not supported as overrides in Classic.

09

In a Lightning web component, a button inside a deeply nested child must fire an event that a component several levels up handles, and the event must cross shadow DOM boundaries. How should the custom event be configured?

  1. bubbles: true, composed: true
  2. bubbles: true, composed: false
  3. bubbles: false, composed: true
  4. bubbles: false, composed: false
Show answer

Answer: A

A. bubbles: true, composed: true ✓Correct. The event bubbles and crosses shadow boundaries.
B. bubbles: true, composed: falseThe event bubbles only inside its own shadow tree.
C. bubbles: false, composed: trueWithout bubbling, the event does not move up the tree.
D. bubbles: false, composed: falseThis is the default and the event reaches only the host.

Why: bubbles: true lets the event move up the DOM tree, and composed: true lets it cross shadow boundaries, so ancestors in other shadow trees can handle it.

10

A field service company has a Lightning web component on the Work Order record page that must load related parts from Apex as soon as the component is inserted into the DOM, but only once. In which lifecycle hook should the developer make the imperative Apex call?

  1. constructor()
  2. connectedCallback()
  3. renderedCallback()
  4. disconnectedCallback()
Show answer

Answer: B

A. constructor()The constructor runs before the component is inserted and before public properties such as recordId are set, so it is not the right place for data loading.
B. connectedCallback() ✓Correct. connectedCallback() fires when the component is inserted into the DOM, public properties are available, and it is the recommended hook for one-time data loading.
C. renderedCallback()renderedCallback() fires after every render, so the call would repeat unless guarded with a flag; it is meant for DOM work after rendering.
D. disconnectedCallback()disconnectedCallback() fires when the component is removed from the DOM and is used for cleanup, not initial loading.

Why: In LWC, connectedCallback() is the standard place for one-time initialization such as loading data or subscribing to channels. renderedCallback() can run many times.

11

A Lightning web component wires the Apex method getOpenTickets to the property tickets. After the user clicks Close Ticket, the component calls an imperative Apex method that updates the record. The list still shows the closed ticket. What should the developer do to show current data?

  1. Call connectedCallback() again from the click handler so the wire runs a second time.
  2. Remove cacheable=true from getOpenTickets so the wire never caches results.
  3. Call refreshApex(this.tickets) after the update succeeds.
  4. Set this.tickets = undefined so the wire service fetches the data again.
Show answer

Answer: C

A. Call connectedCallback() again from the click handler so the wire runs a second time.Calling a lifecycle hook manually does not re-run a wire adapter; the wire only reprovisions when its reactive parameters change or refreshApex() is called.
B. Remove cacheable=true from getOpenTickets so the wire never caches results.A method used with @wire must be cacheable=true; removing it breaks the wire.
C. Call refreshApex(this.tickets) after the update succeeds. ✓Correct. refreshApex() from @salesforce/apex takes the value provisioned by the wire and asks the server for fresh data, updating the cache and the component.
D. Set this.tickets = undefined so the wire service fetches the data again.Wired properties are managed by the wire service; clearing the property does not trigger a new request.

Why: When data behind a wired Apex method changes through imperative Apex or DML, call refreshApex() on the wired value to refresh the client cache.

12

A search page for a parts distributor builds a query from user input in its Apex controller: String soql = 'SELECT Id, Name FROM Part__c WHERE Name LIKE \'%' + searchText + '%\''; List<Part__c> parts = Database.query(soql); Which two changes protect the page from SOQL injection? (Choose 2)

  1. Use a bind variable, for example WHERE Name LIKE :pattern, with pattern built from the input.
  2. Declare the controller class with the without sharing keyword.
  3. Pass the input through String.escapeSingleQuotes() before adding it to the query string.
  4. Wrap the input with HTMLENCODE() in the Visualforce page before sending it to the controller.
  5. Add a LIMIT 200 clause to the end of the query string.
Show answer

Answer: A, C

A. Use a bind variable, for example WHERE Name LIKE :pattern, with pattern built from the input. ✓Correct. Bind variables are treated as data, not as part of the query text, so input cannot change the query structure.
B. Declare the controller class with the without sharing keyword.Sharing keywords control record access; they do nothing to stop injected query text.
C. Pass the input through String.escapeSingleQuotes() before adding it to the query string. ✓Correct. escapeSingleQuotes() escapes single quotes so user input stays inside the string literal and cannot add new clauses.
D. Wrap the input with HTMLENCODE() in the Visualforce page before sending it to the controller.HTMLENCODE() protects against XSS in HTML output; it is not designed to sanitize SOQL query text.
E. Add a LIMIT 200 clause to the end of the query string.A LIMIT clause limits rows returned, but injected text can still change the WHERE logic.

Why: Prevent SOQL injection by using static SOQL with bind variables where possible, or by escaping input with String.escapeSingleQuotes() when dynamic SOQL is required.

13

A developer writes a controller extension for a Visualforce page that uses the Opportunity standard controller. Which constructor signature must the extension class have?

  1. public OppExtension(Opportunity opp)
  2. public OppExtension(ApexPages.StandardSetController setCon)
  3. public OppExtension()
  4. public OppExtension(ApexPages.StandardController stdController)
Show answer

Answer: D

A. public OppExtension(Opportunity opp)The platform does not pass the record itself; it passes the standard controller instance.
B. public OppExtension(ApexPages.StandardSetController setCon)StandardSetController is passed when the page uses a standard list controller with recordSetVar, not a single-record standard controller.
C. public OppExtension()A no-argument constructor is used by custom controllers; an extension of a standard controller needs the controller as a parameter.
D. public OppExtension(ApexPages.StandardController stdController) ✓Correct. An extension of a standard controller must have a constructor that takes one ApexPages.StandardController argument.

Why: Controller extensions receive the controller they extend in their constructor: ApexPages.StandardController for a single record, or the custom controller class when extending a custom controller.

14

A Lightning web component has a field filters = { region: 'North', tier: 'Gold' }; that the template displays. When a handler runs this.filters.region = 'South';, the template does not update. What is the simplest fix?

  1. Decorate the field with @api so the framework watches it.
  2. Call this.render() after changing the property.
  3. Decorate the field with @track, or assign a new object such as this.filters = { ...this.filters, region: 'South' }.
  4. Move the object into a getter that returns a copy of filters.
Show answer

Answer: C

A. Decorate the field with @api so the framework watches it.@api makes the field public to parent components; it does not make internal property changes reactive.
B. Call this.render() after changing the property.There is no supported manual render call for this case; LWC re-renders based on reactivity.
C. Decorate the field with @track, or assign a new object such as this.filters = { ...this.filters, region: 'South' }. ✓Correct. Fields are reactive to reassignment, but changes to an object's inner properties are only tracked when the field uses @track; reassigning a new object also triggers a re-render.
D. Move the object into a getter that returns a copy of filters.A getter recalculates on render, but the component still does not re-render because the original change was not observed.

Why: All LWC fields are reactive when reassigned. To observe changes inside plain objects or arrays, decorate the field with @track or assign a new object or array.

15

A healthcare provider wants a read-only panel on the Patient__c record page that shows six fields in a custom two-column layout with custom section headings. The fields must respect field-level security, and the developer does not want to write Apex. Which base components should the developer use?

  1. lightning-record-edit-form with lightning-input-field components
  2. lightning-datatable with columns for each field
  3. lightning-record-form with mode="readonly" and the fields attribute
  4. lightning-record-view-form with lightning-output-field components
Show answer

Answer: D

A. lightning-record-edit-form with lightning-input-field componentslightning-record-edit-form is meant for creating and editing records; it shows editable inputs, not a read-only panel.
B. lightning-datatable with columns for each fieldlightning-datatable shows rows of records in a table and needs data supplied to it; it is not designed for a single-record custom layout.
C. lightning-record-form with mode="readonly" and the fields attributelightning-record-form is quick to set up but controls the layout itself, so a custom two-column layout with section headings is not possible.
D. lightning-record-view-form with lightning-output-field components ✓Correct. lightning-record-view-form shows read-only field values through Lightning Data Service and lets the developer place each lightning-output-field in a custom layout.

Why: Use lightning-record-form for the fastest standard layout, lightning-record-view-form for custom read-only layouts, and lightning-record-edit-form for custom editable layouts. All use Lightning Data Service.

16

A developer adds a Lightning web component to the Case record page in Lightning App Builder. The component must know the ID of the case being viewed without any extra configuration by the admin. What should the developer do?

  1. Read the ID from window.location.pathname in connectedCallback().
  2. Declare a public property with @api recordId; in the component's JavaScript.
  3. Import the ID with import caseId from '@salesforce/schema/Case.Id';
  4. Wire the getRecord adapter without parameters so it returns the current record.
Show answer

Answer: B

A. Read the ID from window.location.pathname in connectedCallback().Parsing the URL is fragile and does not work in every container; the record page provides the ID directly.
B. Declare a public property with @api recordId; in the component's JavaScript. ✓Correct. On a record page, the framework automatically sets the @api recordId property (and @api objectApiName if declared) to the current record.
C. Import the ID with import caseId from '@salesforce/schema/Case.Id';@salesforce/schema imports a field reference, not the value of the current record's ID.
D. Wire the getRecord adapter without parameters so it returns the current record.getRecord needs a recordId parameter; it does not detect the current record on its own.

Why: Lightning record pages pass context to components through the public properties recordId and objectApiName when the component declares them with @api.

17

A Lightning web component on the Home page must show only the Task records assigned to the current user, using the getRecord-style reactive pattern to look up the user's details. How can the component get the current user's ID without Apex?

  1. Import it with import userId from '@salesforce/user/Id';
  2. Declare @api recordId; and rely on the Home page to set it.
  3. Read UserInfo.getUserId() from the component's JavaScript.
  4. Import it with import userId from '@salesforce/schema/User.Id';
Show answer

Answer: A

A. Import it with import userId from '@salesforce/user/Id'; ✓Correct. The @salesforce/user module provides the current user's ID (and isGuest), which can then be used as a reactive wire parameter.
B. Declare @api recordId; and rely on the Home page to set it.The Home page is not a record page, so recordId is not set to the user's ID.
C. Read UserInfo.getUserId() from the component's JavaScript.UserInfo is an Apex class and cannot be called directly from LWC JavaScript.
D. Import it with import userId from '@salesforce/schema/User.Id';A schema import returns a field reference for the User object, not the current user's ID value.

Why: Scoped modules such as @salesforce/user/Id, @salesforce/label, @salesforce/resourceUrl, and @salesforce/schema give LWC access to org context without Apex.

18

An Aura component will be placed on the Contract record page and must read the current record's ID in its controller. Which two interfaces should the component implement? (Choose 2)

  1. flexipage:availableForAllPageTypes
  2. force:hasRecordId
  3. force:lightningQuickAction
  4. flexipage:availableForRecordHome
  5. lightning:isUrlAddressable
Show answer

Answer: B, D

A. flexipage:availableForAllPageTypesThis interface makes the component available on app pages, Home pages, and record pages, but it does not provide the record ID.
B. force:hasRecordId ✓Correct. force:hasRecordId adds a recordId attribute that is set to the current record's ID on a record page.
C. force:lightningQuickActionThis interface makes the component usable as a quick action, which is not what is asked.
D. flexipage:availableForRecordHome ✓Correct. flexipage:availableForRecordHome makes the component available on record pages in Lightning App Builder.
E. lightning:isUrlAddressableThis interface allows navigation to the component by URL; it does not place it on a record page.

Why: Aura components use marker interfaces such as flexipage:availableForRecordHome for placement and force:hasRecordId or force:hasSObjectName to receive record context.

19

A parent Lightning web component has a Reset button. When it is clicked, a child component c-search-panel must clear its search fields. How should the developer implement this?

  1. In the child, expose a method with @api reset(), and in the parent call this.template.querySelector('c-search-panel').reset().
  2. In the parent, dispatch a custom event named reset that the child listens for.
  3. In the parent, call document.querySelector('c-search-panel').reset().
  4. In the child, decorate the search fields with @wire so they reset when the parent re-renders.
Show answer

Answer: A

A. In the child, expose a method with @api reset(), and in the parent call this.template.querySelector('c-search-panel').reset(). ✓Correct. Public methods decorated with @api can be called by the parent on the child element it owns.
B. In the parent, dispatch a custom event named reset that the child listens for.Custom events bubble up from child to parent; a child does not receive events dispatched by its parent this way.
C. In the parent, call document.querySelector('c-search-panel').reset().document.querySelector does not cross shadow boundaries and should not be used to reach elements in a component's template.
D. In the child, decorate the search fields with @wire so they reset when the parent re-renders.@wire provisions data from wire adapters; it does not clear fields when a parent re-renders.

Why: Parents communicate down to children through @api properties and @api methods; children communicate up through custom events.

20

Admins must be able to set a Max Rows value for a Lightning web component each time they drop it on an app page in Lightning App Builder. What must the developer do?

  1. Create a custom setting named Max_Rows__c and read it in the component.
  2. Add a custom label named Max_Rows and import it in the component.
  3. Declare @api maxRows in the JavaScript and add a <property name="maxRows" type="Integer"> inside a targetConfig for lightning__AppPage in js-meta.xml.
  4. Declare maxRows with @track and set a default value in the HTML template.
Show answer

Answer: C

A. Create a custom setting named Max_Rows__c and read it in the component.A custom setting gives one org-wide or profile-level value, not a separate value per component instance on a page.
B. Add a custom label named Max_Rows and import it in the component.Custom labels hold translatable text and are not configured per page instance in Lightning App Builder.
C. Declare @api maxRows in the JavaScript and add a <property name="maxRows" type="Integer"> inside a targetConfig for lightning__AppPage in js-meta.xml. ✓Correct. Properties defined in targetConfigs appear in the Lightning App Builder property panel and set the matching @api property.
D. Declare maxRows with @track and set a default value in the HTML template.@track makes a private field reactive; it does not expose a setting to admins in Lightning App Builder.

Why: Design-time properties for LWC are defined with <property> elements inside <targetConfig> in the js-meta.xml file and must match public @api properties.

Find out if you're ready to pass

Take the free Platform Developer diagnostic: 20 questions, no account needed. Then unlock all 300 questions, full practice exams and the study guide.

Start the free diagnosticSee plans

Other sections of this exam