1. How do you import a module in a Lightning Web Component?

a) Using the <import> tag in the component's HTML file

b) Using the import keyword in the component's JavaScript file

c) Using the <script> tag in the component's HTML file

d) Importing modules is not supported in Lightning Web Components


2. Which of the following is NOT a valid lifecycle hook in Lightning Web Components?

a) renderCallback

b) renderedCallback

c) errorCallback

d) disconnectedCallback


3. What is the purpose of the renderedCallback() lifecycle hook in LWC?

a) It is called when the component is initialized.

b) It is called after the component is rendered.

c) It is called when the component's attribute values change.

d) It is called when the component is removed from the DOM.


4. How do you handle user input events in Lightning Web Components?

a) Using inline event handlers like onclick or onchange

b) Using event listeners in the JavaScript file

c) Using CSS animations

d) Using Visualforce components


5. What is the role of the @wire decorator in Lightning Web Components?

a) It is used to wire the component to Salesforce data.

b) It is used to define public properties in the component.

c) It is used to track changes to properties in the component.

d) It is used to import modules from external sources.


6. In LWC, where do you define the component's public API?

a) In the JavaScript file using the @api decorator

b) In the HTML file using the <public-api> tag

c) In the metadata file using the api property

d) In the Apex controller class


7. How can you access query parameters in Lightning Web Components?

a) Using JavaScript fetch API

b) Using Apex controllers

c) Using the @wire decorator

d) Using the NavigationMixin


8.What is the recommended way to debug Lightning Web Components?

a) Using console.log statements in the JavaScript file

b) Using the Lightning Inspector browser extension

c) Using the Developer Console in Salesforce

d) All of the above


9. Which attribute is used to pass data from a parent component to a child component in LWC?

a) data-attribute

b) component-attribute

c) public-attribute

d) aura-attribute


10. What is the purpose of the track attribute in Lightning Web Components?

a) It defines a property as reactive and tracks its changes.

b) It defines a property as a public API.

c) It defines a property as a global variable.

d) It defines a property as immutable.


Answer Key: 

1. b) Using the import keyword in the component's JavaScript file

  1. a) renderCallback
  2. b) It is called after the component is rendered.
  3. b) Using event listeners in the JavaScript file
  4. a) It is used to wire the component to Salesforce data.
  5. a) In the JavaScript file using the @api decorator
  6. d) Using the NavigationMixin
  7. d) All of the above
  8. a) data-attribute
  9. a) It defines a property as reactive and tracks its changes.