PD1 User Interface 4 β Questions and Answers
Question 1: A developer must prevent a Lightning Web Component from being dropped onto App Builder pages by non-admin users. Which configuration achieves this?
- Set isExposed to false in js-meta.xml (Correct answer)
- Remove the <targets> element from js-meta.xml
- Add requiresAdminPermission='true' to the component decorator
- Set visibility='admin' in js-meta.xml
Correct answer: Set isExposed to false in js-meta.xml
Setting <isExposed>false</isExposed> in the js-meta.xml file hides the component from App Builder entirely.
Question 2: In LWC, how do you pass data from a parent component to a child component?
- Use a shared Apex controller method
- Set the child's @api property via an HTML attribute on the child's element in parent markup (Correct answer)
- Dispatch a custom event from the parent
- Use the wire service to share data between components
Correct answer: Set the child's @api property via an HTML attribute on the child's element in parent markup
Parent-to-child data flow in LWC uses HTML attributes on the child tag that map to @api-decorated properties in the child component.
Question 3: Which statement correctly describes the Locker Service in Salesforce Lightning?
- It encrypts field-level data before sending it to the browser
- It isolates component JavaScript so components cannot access each other's DOM or globals directly (Correct answer)
- It locks a record from editing when another user has it open
- It prevents SOQL injection in Apex called from Lightning components
Correct answer: It isolates component JavaScript so components cannot access each other's DOM or globals directly
Locker Service enforces component isolation by wrapping DOM access and JS globals in secure proxies, preventing cross-component DOM access.
Question 4: A Visualforce page uses a custom controller. The developer wants to access the record ID of the current page. Which approach is correct?
- Use ApexPages.currentPage().getParameters().get('id') in the controller (Correct answer)
- Use {!$CurrentPage.recordId} in the page markup
- Pass the ID through a hidden <apex:inputHidden> tag
- Use Schema.SObjectType to retrieve the current record ID
Correct answer: Use ApexPages.currentPage().getParameters().get('id') in the controller
ApexPages.currentPage().getParameters().get('id') retrieves the 'id' URL parameter, which Salesforce automatically appends when navigating to a standard record page.
Question 5: In an LWC template, what syntax correctly renders a list of items from a 'contacts' property?
- <template for:each={contacts} for:item='contact'> (Correct answer)
- <template lwc:for={contacts} lwc:item='contact'>
- <template aura:iteration='contacts'>
- <ul lwc:repeat={contacts}>
Correct answer: <template for:each={contacts} for:item='contact'>
LWC uses for:each and for:item directives on a <template> tag; each child element must also carry a unique key attribute.
Question 6: What is the role of the lightning-record-view-form component in LWC?
- To provide an editable form backed by Lightning Data Service
- To display record field values in read-only mode using Lightning Data Service (Correct answer)
- To render a Visualforce component inline within an LWC
- To show a compact record layout in a popover
Correct answer: To display record field values in read-only mode using Lightning Data Service
lightning-record-view-form fetches and displays record data in read-only mode, leveraging Lightning Data Service for caching and FLS.
Question 7: A developer wants a Visualforce page to skip the standard page header and sidebar. Which apex:page attributes accomplish this?
- showHeader='false' sidebar='false' (Correct answer)
- header='none' sidebar='none'
- renderHeader='false' renderSidebar='false'
- showHeader='false' showSidebar='false'
Correct answer: showHeader='false' sidebar='false'
The showHeader and sidebar attributes on <apex:page> accept boolean values to hide the standard Salesforce UI chrome.
A developer must prevent a Lightning Web Component from being dropped onto App Builder pages by non-admin users.
Which configuration achieves this?