MCQs / Computer Science / Windows Mobile, Eclipse and Fragments

Windows Mobile, Eclipse and Fragments MCQs — Computer Science (page 2)

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.

26. Which method makes the Back button undo a fragment transaction?

  1. hide()
  2. commitNow()
  3. setReorderingAllowed()
  4. addToBackStack()

Answer: D) addToBackStack()

Explanation: addToBackStack saves the transaction on the back stack.

Discuss this question

27. Which callback is called when the fragment's view hierarchy is removed?

  1. onDestroyView()
  2. onPause()
  3. onDetach()
  4. onAttach()

Answer: A) onDestroyView()

Explanation: onDestroyView() is called when the view is destroyed; the fragment object may survive.

Discuss this question

28. Which is NOT an advantage of Android Studio over Eclipse ADT?

  1. Gradle-based builds with variants
  2. Better layout editor and Lint
  3. Built-in Kotlin support
  4. It requires Ant scripts for every build

Answer: D) It requires Ant scripts for every build

Explanation: Ant was the old Eclipse approach; Android Studio uses Gradle.

Discuss this question

29. The recommended modern way for two fragments to share data is:

  1. A shared ViewModel scoped to the activity
  2. Restarting the activity
  3. Writing to a text file
  4. Calling each other's methods directly

Answer: A) A shared ViewModel scoped to the activity

Explanation: activityViewModels() gives both fragments the same ViewModel.

Discuss this question

30. Microsoft's current framework for cross-platform mobile apps in C is:

  1. WinForms Mobile
  2. XNA
  3. Silverlight
  4. .NET MAUI

Answer: D) .NET MAUI

Explanation: .NET MAUI (successor of Xamarin) builds Android, iOS, Windows and macOS apps.

Discuss this question

31. The recommended XML container for fragments is:

  1. FragmentContainerView
  2. ScrollView
  3. FrameLayout only
  4. RecyclerView

Answer: A) FragmentContainerView

Explanation: FragmentContainerView is the AndroidX container designed for fragments.

Discuss this question

32. The recommended way to pass initial data to a new fragment is:

  1. A global variable
  2. A constructor with parameters
  3. A static field in the activity
  4. Setting its arguments Bundle

Answer: D) Setting its arguments Bundle

Explanation: Arguments survive fragment recreation; custom constructors do not.

Discuss this question

33. The class that adds, replaces and removes fragments is the:

  1. ActivityManager
  2. FragmentManager
  3. PackageManager
  4. WindowManager

Answer: B) FragmentManager

Explanation: FragmentManager performs fragment transactions.

Discuss this question

34. The master–detail pattern on tablets uses fragments to:

  1. Show a list and the selected item's details side by side
  2. Run two apps at once
  3. Download data in the background
  4. Encrypt files

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.

Discuss this question

35. UWP stands for:

  1. Universal Wireless Protocol
  2. Unified Web Phone
  3. Universal Windows Platform
  4. User Window Process

Answer: C) Universal Windows Platform

Explanation: UWP let one app run on PC, phone, Xbox and HoloLens.

Discuss this question

36. Eclipse ADT used which build tool, later replaced by Gradle in Android Studio?

  1. Ant
  2. Bazel
  3. Maven only
  4. Make

Answer: A) Ant

Explanation: Eclipse-based Android projects were built with Ant scripts.

Discuss this question

37. Which fragment subclass is used to show dialogs that survive rotation?

  1. ListFragment
  2. DialogFragment
  3. PreferenceActivity
  4. MapFragment only

Answer: B) DialogFragment

Explanation: DialogFragment manages dialogs with a proper lifecycle.

Discuss this question

38. Android Studio 1.0 (stable) was released in:

  1. 2008
  2. 2019
  3. 2011
  4. December 2014

Answer: D) December 2014

Explanation: Android Studio was announced at I/O 2013 and reached 1.0 in December 2014.

Discuss this question

39. XAML is used in Windows Phone/UWP apps to:

  1. Sign packages
  2. Describe the user interface in an XML-based markup
  3. Compile C code
  4. Store databases

Answer: B) Describe the user interface in an XML-based markup

Explanation: XAML is a declarative XML-based UI language.

Discuss this question

40. A Fragment is best described as:

  1. A separate app
  2. A background service
  3. A reusable portion of UI with its own lifecycle hosted inside an activity
  4. A database table

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.

Discuss this question

Previous Page 2 of 2

Practise Windows Mobile, Eclipse and Fragments MCQs

More Computer Science chapters