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: Any Holo theme DarkActionBar Translucent 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: Programmatic (dynamic) UI creation Resource qualification Inflation 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: setOnScrollListener setOnClickListener setOnTouchMoveListener setOnLongClickListener Answer: D) setOnLongClickListener
Explanation: setOnLongClickListener handles long presses.
Discuss this question
4. Dark-theme specific colours are stored in: values-dark values-black drawable-night only 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? supportActionBar?.showBack() finish() toolbar.upEnabled = 1 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? Notification Toast Snackbar 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? setOnCheckedChangeListener setOnLongClickListener setOnClickListener 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: Overflow menu Popup window Notification panel 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: Cannot have colours Is written in Kotlin Applies to a whole activity or app, while a style applies to individual views 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? registerForContextMenu(view) setContextMenu(true) invalidateOptionsMenu() 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? Toolbar, Menu and Dialog LayoutManager, Adapter and ViewHolder Intent, Bundle and Service 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? onOptionsItemSelected() onContextItemSelected() onMenuOpened() onClick() Answer: A) onOptionsItemSelected()
Explanation: onOptionsItemSelected receives the selected MenuItem.
Discuss this question
13. Which spacing system does Material Design recommend? 5 px grid 8 dp grid 12 sp grid 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: 2008 2014 2019 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: @Composable @UI @IBOutlet @Override Answer: A) @Composable
Explanation: Composable functions describe the UI.
Discuss this question
16. Which is an advantage of Toolbar over the default ActionBar? It cannot be styled It is a normal View that can be placed, styled and animated anywhere It does not support menus 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: Skeuomorphic textures Removal of dark mode Dynamic colours based on the user's wallpaper 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: onCreate() onPrepareOptionsMenu() onDestroyOptionsMenu() 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: onContextItemSelected() onOptionsItemSelected() onCreateContextMenu() 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: Chip RadioButton Floating Action Button (FAB) 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: Always appears in the overflow Never appears Appears in the app bar if there is space, otherwise in the overflow 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? always never withText 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? It runs faster than any other method It is the only way to create UI Separation of design from code and support for alternative layouts 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: android.R.id.home android.R.id.up R.id.up 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: Popup menu Navigation drawer Context menu 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