










































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Complete preparation for software development fundamentals, covering programming, databases, debugging, testing, version control, software design, web basics, security, and development workflows.
Typology: Exams
1 / 50
This page cannot be seen from the preview
Don't miss anything!











































Question 1. In a Magento 2 theme, which file is primarily responsible for defining RequireJS module paths and shims? A) requirejs-config.js B) module.xml C) di.xml D) webpack.config.js Answer: A Explanation: requirejs-config.js is the standard configuration file where developers declare module paths, aliases, and shims for non-AMD libraries. Question 2. When two RequireJS configurations define the same alias, which one takes precedence? A) The one in the parent theme B) The one in the child theme or module that loads later C) The one with the highest version number D) The one defined in lib/web/requirejs-config.js Answer: B Explanation: Magento merges RequireJS configs in load order; later (more specific) configurations override earlier ones. Question 3. Which of the following statements about RequireJS “mixins” is true? A) Mixins replace the original module entirely. B) Mixins allow adding new methods without changing the original source. C) Mixins can only be used with jQuery widgets. D) Mixins are defined in di.xml. Answer: B Explanation: Mixins are a way to extend or modify existing AMD modules by injecting additional functionality while preserving the original code. Question 4. To integrate a legacy library that does not support AMD, which RequireJS property must be used?
A) map B) shim C) deps D) bundles Answer: B Explanation: The shim configuration tells RequireJS how to export a non-AMD script and its dependencies. Question 5. What is the purpose of the data-mage-init attribute in Magento 2 markup? A) To load CSS files dynamically. B) To initialize a JavaScript component with JSON configuration. C) To define a new RequireJS module. D) To create a server-side block. Answer: B Explanation: data-mage-init contains a JSON object that tells Magento which UI component to instantiate on that HTML element. Question 6. How does x-magento-init differ from data-mage-init? A) x-magento-init is processed server-side, while data-mage-init is client-side. B) x-magento-init can target multiple elements with a single JSON block, whereas data-mage-init works per element. C) x-magento-init is deprecated. D) There is no functional difference; they are synonyms. Answer: B Explanation: x-magento-init is placed in a script tag and can initialize components for many selectors at once, while data-mage-init attaches configuration directly to an element. Question 7. In a UI component XML declaration, which attribute links a component to a data provider? A) name
C) datepicker D) foreach Answer: C Explanation: datepicker is not a core Knockout binding; it is provided by a custom Magento UI component or jQuery UI widget. Question 11. When overriding a UI component’s template, which directory structure should be used in a custom module? A) view/frontend/templates/ui/component.html B) view/adminhtml/web/template/component.html C) view/frontend/web/template/component.html D) view/adminhtml/templates/component.html Answer: C Explanation: UI component templates live under view//web/template/ and are referenced by their relative path. Question 12. Which Magento 2 JavaScript module is used to build URLs for AJAX calls? A) mage/storage B) mage/url C) mage/translate D) mage/validation Answer: B Explanation: mage/url provides the build method to generate URLs respecting store view, base URLs, and query parameters. Question 13. What is the primary purpose of the mage/storage module? A) To store configuration values in local storage. B) To perform client-side caching of AJAX responses. C) To manage session cookies. D) To translate strings.
Answer: B Explanation: mage/storage offers a simple key-value storage that can cache AJAX responses in the browser’s local storage. Question 14. In the checkout, which JavaScript object contains the configuration data sent from the backend? A) checkoutData B) checkoutConfig C) shippingConfig D) paymentConfig Answer: B Explanation: checkoutConfig is a global JS object populated by the server and accessed by the checkout UI components. Question 15. How can a developer add a new step to the Magento 2 checkout flow? A) Modify checkout_index_index.xml layout file. B) Register the step via stepNavigator.registerStep. C) Add a new template file under checkout/step. D) Edit the checkoutConfig JSON directly. Answer: B Explanation: stepNavigator.registerStep is the API used to inject custom steps into the checkout’s step sequence. Question 16. Which event is dispatched after the shipping address is saved in checkout? A) shippingAddressUpdatedAfter B) checkoutShippingAddressSaveAfter C) checkout_shipping_address_save_after D) checkoutShippingAddressUpdateAfter Answer: D
Question 20. Where is the sections.xml file located for defining private customer data sections? A) app/code/Vendor/Module/etc/frontend/sections.xml B) app/code/Vendor/Module/view/frontend/layout/sections.xml C) app/code/Vendor/Module/etc/sections.xml D) app/code/Vendor/Module/web/sections.xml Answer: A Explanation: sections.xml resides under etc/frontend/ (or etc/webapi_rest/) to declare which data sections should be refreshed via AJAX. Question 21. Which Magento 2 JavaScript module is used to publish and subscribe to events across unrelated components? A) mage/event-manager B) mage/events C) mage/pubsub D) mage/bus Answer: B Explanation: mage/events provides a simple pub/sub mechanism that UI components can use to communicate without direct references. Question 22. To add a custom validation rule that checks if a field contains only uppercase letters, which method should be used? A) $.validator.addMethod('uppercase', function(value){...}); B) validator.addRule('uppercase', function(){...}); C) $.mage.validation.add('uppercase', function(){...}); D) $.ui.validation.addMethod('uppercase', function(){...}); Answer: A Explanation: jQuery Validation’s addMethod is the standard way to register a new rule; Magento’s UI components rely on this library.
Question 23. Which Chrome DevTools panel is most useful for inspecting Knockout.js view models? A) Elements B) Console C) Sources (Watch) D) Network Answer: C Explanation: The Sources panel’s “Watch” or “Scope” sections let you view the current JavaScript objects, including Knockout view models. Question 24. When enabling JavaScript bundling in production mode, which file contains the list of bundled modules? A) requirejs-config.js B) bundling.js C) bundle.min.js D) bundling-config.json Answer: C Explanation: bundle.min.js (or bundle.js in developer mode) is the output file that aggregates all required modules. Question 25. Which Magento 2 module provides the mage/translate functionality? A) Magento_Translation B) Magento_Customer C) Magento_Theme D) Magento_Translation is not a module; mage/translate is a core JS library. Answer: D Explanation: mage/translate is a core JavaScript library bundled with Magento; it is not tied to a separate Magento module. Question 26. To prevent XSS when inserting user-generated content into a Knockout template, which binding should be used?
B) observableArray() C) computed() D) pureComputed() Answer: B Explanation: observableArray is designed to hold arrays and works seamlessly with the foreach binding. Question 30. When customizing checkout payment methods, which JavaScript component must be extended to add a new field to the payment form? A) payment-method-list B) payment-information C) checkout-payment-method D) payment-method-view Answer: D Explanation: payment-method-view is the UI component responsible for rendering the individual payment method form and can be extended via mixins. Question 31. Which Magento 2 UI component lifecycle hook is called after all observables have been initialized but before the component is rendered? A) initialize() B) initObservable() C) beforeRender() D) afterRender() Answer: C Explanation: beforeRender runs after observables are set up and allows final tweaks before the template is processed. Question 32. In the checkout, which JavaScript file contains the definition of stepNavigator? A) Magento_Checkout/js/model/step-navigator B) Magento_Checkout/js/view/step-navigator
C) Magento_Checkout/js/action/step-navigator D) Magento_Checkout/js/model/checkout-data Answer: A Explanation: step-navigator is a model (Magento_Checkout/js/model/step- navigator) that manages the order and visibility of checkout steps. Question 33. Which of the following is the correct way to register a new entry point for RequireJS bundling? A) Add the module name to bundles in requirejs-config.js. B) Place the module in web/js/bundle/. C) Define it in webpack.config.js. D) Use define('my-bundle', ['module1', 'module2']); Answer: A Explanation: The bundles configuration maps a bundle name to an array of module IDs, instructing RequireJS to load them together. Question 34. What does the mage/url method build return when provided with the path "customer/account/login"? A) /customer/account/login/ B) http:///customer/account/login/ C) customer/account/login D) It throws an error. Answer: B Explanation: build constructs a full URL using the store’s base URL, ensuring the correct protocol and trailing slash. Question 35. Which of the following statements about mage/storage is correct? A) It automatically clears data after 5 minutes. B) It stores data in the browser’s sessionStorage by default. C) It provides a set and get API for client-side caching.
Explanation: Custom bindings define an init function (optional) for one-time setup and an update function for reacting to observable changes. Question 39. To modify the mini-cart’s content without affecting Full Page Cache, which Magento feature should be used? A) Private Content sections defined in sections.xml. B) Varnish ESI tags. C) HTTP cookies. D) Server-side rendering. Answer: A Explanation: Private content sections are excluded from FPC and refreshed via AJAX, making them ideal for dynamic mini-cart data. Question 40. Which JavaScript module provides the validate method used by UI components for form validation? A) mage/validation B) jquery/validate C) uiComponent/validation D) mage/formValidator Answer: A Explanation: mage/validation wraps jQuery Validation and exposes the validate method to UI components. Question 41. In Magento 2, which file would you edit to add a new alias for a third-party library called moment.js? A) requirejs-config.js in the module that uses it. B) composer.json in the root. C) di.xml in the module. D) webpack.config.js. Answer: A Explanation: Aliases for JavaScript libraries are defined in requirejs-config.js using the paths configuration.
Question 42. Which of the following is the correct syntax to define a RequireJS shim for a library named legacy.js that depends on jquery and exports a global Legacy object? A) shim: { 'legacy': { deps: ['jquery'], exports: 'Legacy' } } B) shim: { 'legacy.js': { deps: ['jquery'], exports: 'Legacy' } } C) shim: { 'legacy': { deps: ['jquery'], init: function(){ return Legacy; } } } D) shim: { 'legacy': { deps: ['jquery'] } } Answer: A Explanation: The shim entry’s key is the module name (without .js), deps lists dependencies, and exports specifies the global variable. Question 43. When extending a Magento UI component via a mixin, which property of the mixin definition should contain the path to the mixin file? A) config B) mixins C) deps D) requires Answer: B Explanation: In requirejs-config.js, the mixins node maps the original component to an array of mixin file paths. Question 44. Which of the following is NOT a standard step in Magento 2 checkout flow? A) Shipping B) Billing C) Review & Payments D) Wishlist Answer: D Explanation: Wishlist is a separate feature; the checkout steps are Shipping, Billing, and Review & Payments (often combined).
Question 48. Which of the following is the correct way to add a custom CSS class to a Magento UI component via XML? A) my-class B) my-class C) my-class D) my-class Answer: A Explanation: UI components accept arguments; cssClass is a common argument used to add a class to the root element. Question 49. Which method of the mage/events bus is used to listen for an event named myCustomEvent? A) on('myCustomEvent', callback) B) subscribe('myCustomEvent', callback) C) listen('myCustomEvent', callback) D) bind('myCustomEvent', callback) Answer: A Explanation: mage/events follows the jQuery-style on method for event subscription. Question 50. When a new payment method is added, which XML node must be added to payment_methods.xml to make it visible in the checkout? A) B) C) D) Answer: A Explanation: The `` node defines the UI component that renders the payment method in checkout.
Question 51. Which of the following statements about Magento’s JavaScript minification is true? A) It removes all comments, including license notices. B) It is only applied when dev/js/minify_files is set to 1. C) It runs automatically in production mode and creates *.min.js files. D) It requires a separate Grunt task to execute. Answer: C Explanation: In production mode, Magento automatically minifies JS files, generating .min.js assets. Question 52. To translate a string inside a JavaScript file, which syntax should be used? A) $t('Your text') B) $.('Your text') C) $.('Your text', 'Vendor_Module') D) $t('Your text', 'Vendor_Module') Answer: A Explanation: $t is the shortcut provided by mage/translate to fetch the localized version of a string. Question 53. Which of the following is a security best practice when outputting user data in a Knockout template? A) Use the html binding with a sanitization function. B) Use the text binding to automatically escape HTML. C) Disable all bindings and write raw HTML. D) Store the data in a hidden input field. Answer: B Explanation: The text binding escapes any HTML, preventing XSS attacks.
A) addQueryParam B) build with second argument C) appendParams D) setQuery Answer: B Explanation: build accepts a second argument – an object of query parameters – which it appends to the generated URL. Question 58. In the checkout, which observable holds the selected shipping method code? A) selectedShippingMethod B) shippingMethod() C) selectedShippingMethodCode D) shippingMethodCode() Answer: B Explanation: The shippingMethod observable (a function) returns an object containing carrier_code and method_code. Question 59. Which of the following is the correct way to register a new UI component for the admin grid column renderer? A) B) C) D) Vendor_Module/js/grid/columns/my-column Answer: A Explanation: Grid columns are defined with a `` node where the component attribute points to the JS renderer.
Question 60. What does the uiComponent base class provide to all UI components? A) Automatic routing capabilities. B) Methods for initializing observables and handling templates. C) Direct access to the database. D) Server-side rendering. Answer: B Explanation: uiComponent supplies common lifecycle methods (initialize, initObservable, etc.) and template handling for UI components. Question 61. Which of the following statements about mage/storage caching policy is correct? A) Data is cached for the life of the browser session only. B) Cached entries are cleared automatically when the cart changes. C) Developers must manually invalidate entries when underlying data changes. D) It only caches GET requests, never POST. Answer: C Explanation: mage/storage does not automatically invalidate; developers need to call remove or set to update cached entries. Question 62. In a RequireJS map configuration, what does the following entry do? map: { '*': { 'jquery/ui': 'jquery/jquery-ui' } } A) Replaces all references to jquery/ui with jquery/jquery-ui. B) Loads both jquery/ui and jquery/jquery-ui simultaneously. C) Creates an alias named * for both modules. D) Does nothing because * is not a valid key. Answer: A Explanation: The wildcard * applies the mapping to every module; thus any request for jquery/ui is redirected to jquery/jquery-ui.