26. Which method makes the Back button undo a fragment transaction?
- hide()
- commitNow()
- setReorderingAllowed()
- addToBackStack()
Answer: D) addToBackStack()
Explanation: addToBackStack saves the transaction on the back stack.
MCQs / Computer Science / Windows Mobile, Eclipse and Fragments
40 multiple-choice questions on Windows Mobile, Eclipse and Fragments 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) addToBackStack()
Explanation: addToBackStack saves the transaction on the back stack.
Answer: A) onDestroyView()
Explanation: onDestroyView() is called when the view is destroyed; the fragment object may survive.
Answer: D) It requires Ant scripts for every build
Explanation: Ant was the old Eclipse approach; Android Studio uses Gradle.
Answer: A) A shared ViewModel scoped to the activity
Explanation: activityViewModels() gives both fragments the same ViewModel.
Answer: D) .NET MAUI
Explanation: .NET MAUI (successor of Xamarin) builds Android, iOS, Windows and macOS apps.
Answer: A) FragmentContainerView
Explanation: FragmentContainerView is the AndroidX container designed for fragments.
Answer: D) Setting its arguments Bundle
Explanation: Arguments survive fragment recreation; custom constructors do not.
Answer: B) FragmentManager
Explanation: FragmentManager performs fragment transactions.
Answer: A) Show a list and the selected item's details side by side
Explanation: On large screens two fragments are shown together in one activity.
Answer: C) Universal Windows Platform
Explanation: UWP let one app run on PC, phone, Xbox and HoloLens.
Answer: A) Ant
Explanation: Eclipse-based Android projects were built with Ant scripts.
Answer: B) DialogFragment
Explanation: DialogFragment manages dialogs with a proper lifecycle.
Answer: D) December 2014
Explanation: Android Studio was announced at I/O 2013 and reached 1.0 in December 2014.
Answer: B) Describe the user interface in an XML-based markup
Explanation: XAML is a declarative XML-based UI language.
Answer: C) A reusable portion of UI with its own lifecycle hosted inside an activity
Explanation: Fragments are modular UI pieces living inside an activity.
Previous Page 2 of 2
Practise Windows Mobile, Eclipse and Fragments MCQs