Learn Drupal MCQs

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

Which function is used to add a new field in a custom module?

1) field_create_field()

2) field_add_field()

3) field_add()

4) field_create()

Answer : field_create_field()

What is the purpose of the `hook_form_FORM_ID_alter()` function?

1) To modify a specific form

2) To create a new form

3) To delete a form

4) To render a form

Answer : To modify a specific form

In Drupal, what does `hook_user_presave()` do?

1) Runs before a user is saved

2) Runs after a user is saved

3) Runs when a user logs in

4) Runs when a user logs out

Answer : Runs before a user is saved

What command is used to clear the cache for a specific module in Drush?

1) drush cache-clear module_name

2) drush cc module_name

3) drush clear-cache module_name

4) drush cc

Answer : drush cc module_name

What does the `hook_menu_alter()` function do?

1) Alters menu items

2) Creates new menu items

3) Deletes menu items

4) None of the above

Answer : Alters menu items

Which of the following can be used to manage user permissions in Drupal?

1) Admin interface

2) Drush

3) Both a and b

4) None of the above

Answer : Both a and b

What does the `hook_cron()` function do?

1) Runs tasks periodically

2) Defines custom routes

3) Alters database tables

4) None of the above

Answer : Runs tasks periodically

Which file is used to define a Drupal theme?

1) .info.yml

2) .theme

3) theme-settings.php

4) styles.css

Answer : .info.yml

What is the purpose of `hook_page_attachments()` in Drupal?

1) To add CSS and JavaScript to the page

2) To modify the page title

3) To manage users

4) To create forms

Answer : To add CSS and JavaScript to the page

Which of the following describes a "custom block" in Drupal?

1) A reusable piece of content

2) A user role

3) A type of field

4) A taxonomy term

Answer : A reusable piece of content