Learn Drupal MCQs
Prepare Drupal MCQs (Multiple choice Questions) for exam and job interviews.
Which command in Drush is used to install a module?
1) drush en
2) drush install
3) drush mod-install
4) drush module-enable
Answer : drush en
What does `hook_node_insert()` allow you to do?
1) Perform actions when a node is inserted
2) Delete nodes
3) Update nodes
4) Create new node types
Answer : Perform actions when a node is inserted
What is the purpose of `hook_preprocess_node()` in Drupal?
1) Prepares variables for node templates
2) Creates new nodes
3) Deletes nodes
4) Displays node content
Answer : Prepares variables for node templates
Which function is used to get a field value from a node in Drupal?
1) field_get_value()
2) node_field()
3) node_get_field()
4) get_field_value()
Answer : field_get_value()
What does `hook_menu_links_discovered_alter()` allow you to do?
1) Modify menu links
2) Create new menu links
3) Delete menu links
4) Manage menu access
Answer : Modify menu links
Which file defines services in a Drupal module?
1) module.services.yml
2) module.services.yaml
3) module.services.txt
4) module.services.php
Answer : module.services.yml
What is the function used to check user permissions in Drupal?
1) user_access()
2) drupal_check_access()
3) user_permission()
4) check_permission()
Answer : user_access()
Which Drush command is used to rebuild the Drupal cache?
1) drush cr
2) drush cache-rebuild
3) drush cc all
4) drush cache-clear
Answer : drush cr
What does `hook_entity_presave()` do in Drupal?
1) Performs actions before saving an entity
2) Deletes an entity
3) Updates an entity
4) Creates a new entity
Answer : Performs actions before saving an entity
What is the command to check for available updates in Drupal using Drush?
1) drush pm-updatestatus
2) drush pm-update
3) drush updatestatus
4) drush check-updates
Answer : drush pm-updatestatus