1. Which component shows a brief message with an action button at the bottom of the screen?
- Toast
- Spinner
- ProgressBar
- Snackbar
Answer: D) Snackbar
Explanation: Snackbar can include one action such as OK/Undo.
MCQs / Computer Science / Lab: Menus and Messages
12 multiple-choice questions on Lab: Menus and Messages 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.
Answer: D) Snackbar
Explanation: Snackbar can include one action such as OK/Undo.
Answer: D) The ID of the menu item that was clicked
Explanation: itemId identifies the selected item.
Answer: C) res/menu/mainmenu.xml
Explanation: Menu resources go in res/menu.
Answer: C) app:showAsAction
Explanation: With AppCompat/Material, showAsAction uses the app namespace.
Answer: C) Anchored to the given view
Explanation: A popup menu is anchored to the view passed to its constructor.
Answer: D) android:orderInCategory
Explanation: orderInCategory controls item ordering.
Answer: C) Long-presses a view registered with registerForContextMenu()
Explanation: Context menus appear on long press.
Answer: C) menu.add(groupId, itemId, order, title)
Explanation: Menu.add() creates items programmatically.
Answer: C) A theme with an ActionBar is used together with setSupportActionBar(toolbar)
Explanation: Use a NoActionBar theme when you set a Toolbar as the app bar.
Answer: B) In the overflow (⋮) menu
Explanation: never always places the item in the overflow menu.
Answer: D) menuInflater
Explanation: menuInflater.inflate(R.menu.mainmenu, menu) builds the menu.
Answer: D) true
Explanation: Returning true displays the menu.
Practise Lab: Menus and Messages MCQs