Learn Drupal MCQs

Prepare Drupal MCQs (Multiple choice Questions) for exam and job interviews.

Which of the following is a valid way to define a route in Drupal 8?

1) module_name.route.yml

2) routes.yaml

3) module.routing.yml

4) module.routes.yml

Answer : module_name.route.yml

What is the use of the `drupal_set_message()` function?

1) Display a message to the user

2) Log messages

3) Create new messages

4) Delete messages

Answer : Display a message to the user

In Drupal, what is a block?

1) A container for content

2) A type of node

3) A user role

4) A module

Answer : A user role

What is the purpose of `hook_block_view_alter()`?

1) Modify the content of a block

2) Create new blocks

3) Delete blocks

4) Manage block visibility

Answer : Modify the content of a block

Which command is used to run a Drupal site in maintenance mode?

1) drush sset system.maintenance_mode 1

2) drush maintenance-mode

3) drush site:maintenance-mode

4) drush config:set system.maintenance_mode 1

Answer : drush sset system.maintenance_mode 1

What is the function of `hook_node_presave()`?

1) Modify a node before it is saved

2) Create new nodes

3) Delete nodes

4) Manage node permissions

Answer : Create new nodes

Which of the following is a method to clear the cache in Drupal?

1) drush cr

2) drush cache-clear

3) drush clear-cache

4) drush cache-rebuild

Answer : drush cr

What is the role of the `hook_schema()` function?

1) Define the database schema for a module

2) Create new tables

3) Alter existing tables

4) Drop tables

Answer : Define the database schema for a module

In Drupal, what is a taxonomy?

1) A system for categorizing content

2) A type of content

3) A user group

4) A type of module

Answer : A type of content

What does the `drupal_get_path()` function do?

1) Gets the path of a module or theme

2) Creates a new path

3) Deletes a path

4) Alters a path

Answer : Gets the path of a module or theme