MCQs / Computer Science / Action Bar and User Interface Design

Action Bar and User Interface Design MCQs — Computer Science

34 multiple-choice questions on Action Bar and User Interface Design from Computer Science, each with the correct answer and, where available, a teacher's explanation. Read through them to revise the chapter, then practise the same questions one by one to test yourself.

1. When using a Toolbar as the app bar, the activity theme should be:

  1. Any Holo theme
  2. DarkActionBar
  3. Translucent
  4. A NoActionBar theme

Answer: D) A NoActionBar theme

Explanation: Otherwise two app bars appear (or an exception is thrown).

Discuss this question

2. Creating views with TextView(this) and adding them with addView() is called:

  1. Programmatic (dynamic) UI creation
  2. Resource qualification
  3. Inflation
  4. Data binding

Answer: A) Programmatic (dynamic) UI creation

Explanation: Views can be built in code at run time.

Discuss this question

3. Long-press events are handled with:

  1. setOnScrollListener
  2. setOnClickListener
  3. setOnTouchMoveListener
  4. setOnLongClickListener

Answer: D) setOnLongClickListener

Explanation: setOnLongClickListener handles long presses.

Discuss this question

4. Dark-theme specific colours are stored in:

  1. values-dark
  2. values-black
  3. drawable-night only
  4. values-night

Answer: D) values-night

Explanation: The night qualifier applies in dark mode.

Discuss this question

5. Which call shows the Up (←) arrow in the action bar?

  1. supportActionBar?.showBack()
  2. finish()
  3. toolbar.upEnabled = 1
  4. supportActionBar?.setDisplayHomeAsUpEnabled(true)

Answer: D) supportActionBar?.setDisplayHomeAsUpEnabled(true)

Explanation: setDisplayHomeAsUpEnabled shows the Up button.

Discuss this question

6. Which component shows a short message with an optional "Undo" action at the bottom?

  1. Notification
  2. Toast
  3. Snackbar
  4. AlertDialog

Answer: C) Snackbar

Explanation: Snackbar supports one action button.

Discuss this question

7. Which listener reacts every time the text in an EditText changes?

  1. setOnCheckedChangeListener
  2. setOnLongClickListener
  3. setOnClickListener
  4. addTextChangedListener (TextWatcher)

Answer: D) addTextChangedListener (TextWatcher)

Explanation: TextWatcher callbacks fire on text changes.

Discuss this question

8. The (⋮) three-dot icon in the app bar opens the:

  1. Overflow menu
  2. Popup window
  3. Notification panel
  4. Context menu

Answer: A) Overflow menu

Explanation: Less frequent items appear in the overflow menu.

Discuss this question

9. A theme differs from a style because a theme:

  1. Cannot have colours
  2. Is written in Kotlin
  3. Applies to a whole activity or app, while a style applies to individual views
  4. Can only change text size

Answer: C) Applies to a whole activity or app, while a style applies to individual views

Explanation: Themes are applied app/activity-wide; styles per view.

Discuss this question

10. Which method must be called to enable a context menu on a view?

  1. registerForContextMenu(view)
  2. setContextMenu(true)
  3. invalidateOptionsMenu()
  4. view.longClickable = false

Answer: A) registerForContextMenu(view)

Explanation: registerForContextMenu attaches the view to the activity's context menu.

Discuss this question

11. Which three classes are needed for a RecyclerView list?

  1. Toolbar, Menu and Dialog
  2. LayoutManager, Adapter and ViewHolder
  3. Intent, Bundle and Service
  4. Cursor, Provider and Receiver

Answer: B) LayoutManager, Adapter and ViewHolder

Explanation: RecyclerView uses a layout manager, adapter and view holders.

Discuss this question

12. Which method handles clicks on options menu items?

  1. onOptionsItemSelected()
  2. onContextItemSelected()
  3. onMenuOpened()
  4. onClick()

Answer: A) onOptionsItemSelected()

Explanation: onOptionsItemSelected receives the selected MenuItem.

Discuss this question

13. Which spacing system does Material Design recommend?

  1. 5 px grid
  2. 8 dp grid
  3. 12 sp grid
  4. 3 mm grid

Answer: B) 8 dp grid

Explanation: Spacing in multiples of 8 dp creates consistent rhythm.

Discuss this question

14. Material Design was introduced by Google in:

  1. 2008
  2. 2014
  3. 2019
  4. 2023

Answer: B) 2014

Explanation: Material Design launched with Android 5.0 Lollipop in 2014.

Discuss this question

15. In Jetpack Compose, UI is built with functions annotated with:

  1. @Composable
  2. @UI
  3. @IBOutlet
  4. @Override

Answer: A) @Composable

Explanation: Composable functions describe the UI.

Discuss this question

16. Which is an advantage of Toolbar over the default ActionBar?

  1. It cannot be styled
  2. It is a normal View that can be placed, styled and animated anywhere
  3. It does not support menus
  4. It works only on Android 2.x

Answer: B) It is a normal View that can be placed, styled and animated anywhere

Explanation: Toolbar is flexible and customisable.

Discuss this question

17. Material You (Material 3) introduced:

  1. Skeuomorphic textures
  2. Removal of dark mode
  3. Dynamic colours based on the user's wallpaper
  4. Mandatory action bars

Answer: C) Dynamic colours based on the user's wallpaper

Explanation: Material 3 personalises colour schemes dynamically.

Discuss this question

18. To hide or change menu items before the menu is displayed you use:

  1. onCreate()
  2. onPrepareOptionsMenu()
  3. onDestroyOptionsMenu()
  4. onStop()

Answer: B) onPrepareOptionsMenu()

Explanation: onPrepareOptionsMenu is called before showing; invalidateOptionsMenu triggers it.

Discuss this question

19. Clicks on context menu items are handled in:

  1. onContextItemSelected()
  2. onOptionsItemSelected()
  3. onCreateContextMenu()
  4. onClick()

Answer: A) onContextItemSelected()

Explanation: onContextItemSelected handles context menu selections.

Discuss this question

20. The circular button for the primary action of a screen is the:

  1. Chip
  2. RadioButton
  3. Floating Action Button (FAB)
  4. Overflow button

Answer: C) Floating Action Button (FAB)

Explanation: A FAB represents the main action.

Discuss this question

21. app:showAsAction="ifRoom" means the item:

  1. Always appears in the overflow
  2. Never appears
  3. Appears in the app bar if there is space, otherwise in the overflow
  4. Appears only in landscape

Answer: C) Appears in the app bar if there is space, otherwise in the overflow

Explanation: ifRoom depends on available space.

Discuss this question

22. Which showAsAction value always places an item in the overflow menu?

  1. always
  2. never
  3. withText
  4. ifRoom

Answer: B) never

Explanation: never keeps the item in the overflow.

Discuss this question

23. Which is an advantage of defining UI in XML?

  1. It runs faster than any other method
  2. It is the only way to create UI
  3. Separation of design from code and support for alternative layouts
  4. It needs no resources

Answer: C) Separation of design from code and support for alternative layouts

Explanation: XML keeps layout separate and lets Android choose configuration-specific files.

Discuss this question

24. The menu ID of the Up button handled in onOptionsItemSelected is:

  1. android.R.id.home
  2. android.R.id.up
  3. R.id.up
  4. R.id.back

Answer: A) android.R.id.home

Explanation: The Up/Home button reports android.R.id.home.

Discuss this question

25. A menu anchored to a specific view and shown as a small drop-down is a:

  1. Popup menu
  2. Navigation drawer
  3. Context menu
  4. Options menu

Answer: A) Popup menu

Explanation: PopupMenu is anchored to a view.

Discuss this question

Page 1 of 2 Next

Practise Action Bar and User Interface Design MCQs

More Computer Science chapters