Docsity

Magento 2 Certified Associate Developer Practice Exam Questions, Exams of Technology

Toggle sidebar
bg1
MAGENTO 2 CERTIFIED ASSOCIATE DEVELOPER Practice
Exam
Question 1. **Which file is mandatory for every Magento 2 module to be
recognized by the framework?**
A) registration.php
B) module.xml
C) composer.json
D) di.xml
Answer: A
Explanation: registration.php contains the call to
\Magento\Framework\Component\ComponentRegistrar::register() which tells
Magento that the module exists.
Question 2. **What is the purpose of etc/module.xml in a Magento 2 module?**
A) Define database schema
B) Declare module name, setup version, and dependencies
C) Register JavaScript components
D) List cron jobs
Answer: B
Explanation: etc/module.xml declares the module’s name, its setup version, and
any module dependencies required for load order.
Question 3. **In Magento 2 Dependency Injection, which method is preferred for
obtaining class dependencies?**
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57
pf58
pf59
pf5a
pf5b
pf5c
pf5d
pf5e
pf5f
pf60
pf61
pf62
pf63
pf64

Partial preview of the text

Download Magento 2 Certified Associate Developer Practice Exam Questions and more Exams Technology in PDF only on Docsity!

Exam

Question 1. Which file is mandatory for every Magento 2 module to be recognized by the framework? A) registration.php B) module.xml C) composer.json D) di.xml Answer: A Explanation: registration.php contains the call to \Magento\Framework\Component\ComponentRegistrar::register() which tells Magento that the module exists. Question 2. What is the purpose of etc/module.xml in a Magento 2 module? A) Define database schema B) Declare module name, setup version, and dependencies C) Register JavaScript components D) List cron jobs Answer: B Explanation: etc/module.xml declares the module’s name, its setup version, and any module dependencies required for load order. Question 3. In Magento 2 Dependency Injection, which method is preferred for obtaining class dependencies?

Exam

A) Using the Object Manager directly in the code B) Constructor injection C) Static calls to the class D) Global helper functions Answer: B Explanation: Constructor injection promotes testability and clear dependency definition; direct use of the Object Manager is discouraged in application code. Question 4. Which Magento 2 concept ensures API stability across releases? A) Plugins B) Observers C) Service Contracts (interfaces) D) Preferences Answer: C Explanation: Service contracts define stable interfaces for business services, allowing Magento to change implementations without breaking third‑party code. Question 5. When Magento merges configuration files, which of the following has the highest precedence? A) Global config.xml B) Module’s config.xml

Exam

Explanation: The frontend area loads configuration, layout, and routes intended for the storefront. Question 8. Which file defines custom frontend routes for a module? A) etc/frontend/routes.xml B) etc/adminhtml/routes.xml C) etc/webapi.xml D) etc/di.xml Answer: A Explanation: etc/frontend/routes.xml registers route IDs and frontNames for the storefront. Question 9. In a Magento controller, which method is executed to produce the result? A) render() B) execute() C) run() D) dispatch() Answer: B Explanation: All action controllers implement the execute() method which returns a ResultInterface.

Exam

Question 10. Which ResultFactory type should be used to return JSON data from a controller? A) page B) redirect C) json D) forward Answer: C Explanation: $resultFactory-

create(\Magento\Framework\Controller\ResultFactory::TYPE_JSON) creates a JSON response. Question 11. How can you retrieve a GET parameter named “id” inside a controller action? A) $this->getRequest()->getParam('id') B) $this->request->get('id') C) $this->url->getParam('id') D) $this->_request->get('id') Answer: A Explanation: The Request object provides getParam() to fetch query or post parameters. Question 12. Which class is responsible for persisting data to a specific database table in Magento 2?

Exam

C) $collection->where('field = ?', $value) D) $collection->setFilter('field', $value) Answer: B Explanation: addFieldToFilter() is the standard method for adding conditions to a collection query. Question 15. When using declarative schema, which file defines a new database table? A) db_schema.xml B) schema.xml C) InstallSchema.php D) UpgradeSchema.php Answer: A Explanation: db_schema.xml is the declarative schema file that describes tables, columns, indexes, and foreign keys. Question 16. Which command applies data patches after a module is installed? A) bin/magento setup:upgrade B) bin/magento setup:db-schema:upgrade C) bin/magento setup:di:compile D) bin/magento cache:flush

Exam

Answer: A Explanation: setup:upgrade runs schema and data patches, updating the database to the latest version. Question 17. In the EAV model, which table stores attribute definitions for products? A) catalog_product_entity B) eav_attribute C) catalog_product_entity_int D) eav_entity_type Answer: B Explanation: eav_attribute contains metadata for all attributes across entities, including products. Question 18. Which layout handle is used for the Magento admin “Dashboard” page? A) adminhtml_dashboard_index B) adminhtml_dashboard_index_index C) adminhtml_dashboard_index_grid D) adminhtml_dashboard_index_view Answer: B

Exam

Question 21. When creating a plugin, which method type runs before the original method? A) beforeMethodName B) afterMethodName C) aroundMethodName D) preMethodName Answer: A Explanation: before* methods are executed prior to the original method and can modify arguments. Question 22. Which di.xml element is used to replace a core class with a custom implementation? A) B) C) D) Answer: B Explanation: maps an original class/interface to a custom class, effectively rewriting it. Question 23. Why are final classes and methods not interceptable by plugins? A) They are compiled differently

Exam

B) Magento’s code generation skips them C) Plugins rely on inheritance and method overriding, which final prevents D) They are loaded in a separate autoloader Answer: C Explanation: Final prevents subclassing, so Magento cannot generate an interceptor that overrides the method. Question 24. In an observer class, which method receives the event data? A) execute() B) dispatch() C) process() D) observe() Answer: A Explanation: All observer classes implement the execute(\Magento\Framework\Event\Observer $observer) method. Question 25. Which XML file registers an observer for the “customer_register_success” event in the frontend area? A) etc/events.xml B) etc/frontend/events.xml C) etc/adminhtml/events.xml

Exam

Answer: A Explanation: etc/acl.xml contains nodes that map to menu items and controller actions. Question 28. In adminhtml system.xml, which element defines a dropdown field? A) B) C) D) Answer: A Explanation: type="select" creates a dropdown; the options are provided via source model. Question 29. Which CLI command regenerates the generated code after adding a new plugin? A) bin/magento setup:di:compile B) bin/magento setup:upgrade C) bin/magento cache:clean D) bin/magento setup:static-content:deploy Answer: A

Exam

Explanation: setup:di:compile generates interceptors and other DI code, reflecting new plugins. Question 30. What is the correct way to log a custom message in Magento 2? A) error_log('message'); B) $this->logger->info('message'); C) Mage::log('message'); D) $this->_logger->debug('message'); Answer: B Explanation: Inject \Psr\Log\LoggerInterface and use its info(), debug(), etc., methods. Question 31. Which class provides the request object in a controller? A) \Magento\Framework\App\Request\Http B) \Magento\Framework\App\Response\Http C) \Magento\Framework\App\Action\Context D) \Magento\Framework\HTTP\PhpEnvironment\Request Answer: C Explanation: The Action Context injects the request, response, and other dependencies into the controller.

Exam

A) To create a class at runtime without a PHP file B) To define a type that extends another type with modified arguments C) To register a plugin for an interface D) To declare a preference for an interface Answer: B Explanation: Virtual types inherit from a concrete class but allow you to change constructor arguments without creating a new PHP class. Question 35. Which file is used to add custom JavaScript mixins for a Magento UI component? A) requirejs-config.js B) mixins.js C) view.xml D) component.js Answer: A Explanation: requirejs-config.js maps original component paths to mixin files using the “mixins” configuration. Question 36. In a Magento 2 theme, where are layout XML files typically placed? A) app/design/frontend/Vendor/theme/Magento_Theme/layout/ B) app/design/frontend/Vendor/theme/layout/

Exam

C) app/code/Vendor/Theme/view/frontend/layout/ D) app/design/frontend/Vendor/theme/web/layout/ Answer: A Explanation: Theme-specific layout overrides reside in the module folder (Magento_Theme) inside the theme’s layout directory. Question 37. Which result type should a controller return to perform a 302 redirect to a CMS page? A) redirect B) forward C) page D) raw Answer: A Explanation: The redirect result can be configured with setUrl() to send a 302 response to the desired URL. Question 38. What is the effect of setting “mode” to “developer” in Magento? A) Enables static content signing only B) Turns off caching, enables template path hints, and displays detailed errors C) Enables production‑grade minification D) Disables all cron jobs

Exam

Question 41. Which of the following best describes a “frontend router” in Magento 2? A) A class that maps API endpoints to services B) A configuration that links a URL prefix to a module’s controller namespace C) A PHP script that reads .htaccess rules D) A JavaScript file handling client navigation Answer: B Explanation: The router defined in routes.xml maps a frontName (URL prefix) to a module’s controller classes. Question 42. What is the purpose of the “view.xml” file in a Magento theme? A) Define layout handles B) Configure image dimensions and responsive breakpoints C) Register JavaScript modules D) Set up ACL rules Answer: B Explanation: view.xml contains image size definitions, media URL settings, and other view‑related configurations. Question 43. Which XML tag is used to set a default value for a system configuration field?

Exam

A) B) C)