MCQs / Computer Science / Screen Components and Orientation

Screen Components and Orientation MCQs — Computer Science

40 multiple-choice questions on Screen Components and Orientation 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. A ViewGroup is:

  1. A group of apps
  2. An invisible container that holds and arranges other views
  3. A single button
  4. A type of notification

Answer: B) An invisible container that holds and arranges other views

Explanation: Layouts are ViewGroups that position child views.

Discuss this question

2. Which qualifier targets tablets with a smallest width of at least 600 dp?

  1. layout-tablet
  2. layout-sw600dp
  3. layout-600
  4. layout-large-land

Answer: B) layout-sw600dp

Explanation: sw600dp means smallest width ≥ 600 dp.

Discuss this question

3. A window width of 600–840 dp belongs to which window size class?

  1. Compact
  2. Medium
  3. Expanded
  4. Large-XL

Answer: B) Medium

Explanation: Compact < 600 dp, Medium 600–840 dp, Expanded 840 dp.

Discuss this question

4. Which manifest attribute locks an activity to portrait?

  1. android:screenOrientation="portrait"
  2. android:configChanges="portrait"
  3. android:rotate="false"
  4. android:orientation="portrait"

Answer: A) android:screenOrientation="portrait"

Explanation: screenOrientation fixes the activity's orientation.

Discuss this question

5. How many pixels is 48 dp on an xxhdpi (480 dpi) screen?

  1. 96
  2. 144
  3. 192
  4. 48

Answer: B) 144

Explanation: px = dp × (dpi/160) = 48 × 3 = 144.

Discuss this question

6. Which statement about ViewModel is TRUE?

  1. It survives uninstalling the app
  2. It must be declared in the manifest
  3. It is stored in strings.xml
  4. It survives rotation but not process death (unless SavedStateHandle is used)

Answer: D) It survives rotation but not process death (unless SavedStateHandle is used)

Explanation: ViewModel lives in memory tied to the activity scope.

Discuss this question

7. Bundles in onSaveInstanceState should contain only small data because:

  1. They are sent to the server
  2. They are serialised and limited (about 1 MB per transaction)
  3. Bundles are encrypted
  4. They slow down Gradle

Answer: B) They are serialised and limited (about 1 MB per transaction)

Explanation: Large Bundles cause TransactionTooLargeException.

Discuss this question

8. The baseline density (where 1 dp = 1 px) is:

  1. xhdpi (320)
  2. hdpi (240)
  3. mdpi (160 dpi)
  4. ldpi (120)

Answer: C) mdpi (160 dpi)

Explanation: At 160 dpi one dp equals one pixel.

Discuss this question

9. For apps targeting Android 16/17 on large screens (≥ 600 dp), orientation locks are:

  1. Converted to portrait
  2. Required by Play
  3. Strictly enforced
  4. Ignored – apps must adapt to any orientation and size

Answer: D) Ignored – apps must adapt to any orientation and size

Explanation: Recent Android versions require adaptive apps on large screens.

Discuss this question

10. Space INSIDE a view between its border and content is called:

  1. Padding
  2. Gravity
  3. Weight
  4. Margin

Answer: A) Padding

Explanation: Padding is inside; margin is outside.

Discuss this question

11. By default, rotating the device causes the activity to be:

  1. Moved to another task
  2. Destroyed and recreated
  3. Paused only
  4. Uninstalled

Answer: B) Destroyed and recreated

Explanation: Rotation is a configuration change that recreates the activity.

Discuss this question

12. Converting XML layout into View objects at run time is called:

  1. Binding
  2. Inflating
  3. Compiling
  4. Rendering only

Answer: B) Inflating

Explanation: setContentView and LayoutInflater inflate layouts.

Discuss this question

13. Which attribute aligns the content INSIDE a TextView?

  1. android:layoutmargin
  2. android:layoutgravity
  3. android:orientation
  4. android:gravity

Answer: D) android:gravity

Explanation: gravity positions the content within the view itself.

Discuss this question

14. Which method is used to save small UI state before the activity is destroyed?

  1. onPause()
  2. onSaveInstanceState(outState: Bundle)
  3. finish()
  4. onStop()

Answer: B) onSaveInstanceState(outState: Bundle)

Explanation: Values put into outState are returned in onCreate's savedInstanceState.

Discuss this question

15. Declaring android:configChanges="orientationscreenSize" means:

  1. The app restarts
  2. Landscape layouts load automatically
  3. The activity is not recreated; onConfigurationChanged() is called instead
  4. Rotation is disabled

Answer: C) The activity is not recreated; onConfigurationChanged() is called instead

Explanation: The developer handles the change manually.

Discuss this question

16. In ConstraintLayout, a width of 0dp means:

  1. Match constraints – fill the space between its constraints
  2. The view is invisible
  3. 0 pixels always
  4. wrapcontent

Answer: A) Match constraints – fill the space between its constraints

Explanation: 0dp = match constraint.

Discuss this question

17. Why is a flat ConstraintLayout faster than many nested LinearLayouts?

  1. It disables padding
  2. It does not need XML
  3. It uses the GPU only
  4. Fewer nested ViewGroups means less measuring and drawing work

Answer: D) Fewer nested ViewGroups means less measuring and drawing work

Explanation: Deep hierarchies require more layout passes.

Discuss this question

18. Why should both portrait and landscape layouts use the same view IDs?

  1. Because IDs control colours
  2. To save memory
  3. It is required by Gradle
  4. So the same Kotlin/Java code (findViewById) works with either layout

Answer: D) So the same Kotlin/Java code (findViewById) works with either layout

Explanation: Code references IDs; matching IDs avoid null views.

Discuss this question

19. android:visibility="gone" means the view is:

  1. Deleted from the XML
  2. Hidden and takes no space
  3. Visible but disabled
  4. Hidden but still takes space

Answer: B) Hidden and takes no space

Explanation: gone removes the view from layout; invisible keeps its space.

Discuss this question

20. For Android to use an alternative landscape layout, the file must have:

  1. Java code inside
  2. A different name ending with land
  3. The same file name as the portrait layout
  4. No IDs

Answer: C) The same file name as the portrait layout

Explanation: Android selects between files of the same name in qualified folders.

Discuss this question

21. wrapcontent makes a view:

  1. Zero size
  2. As big as its content requires
  3. Exactly 100 dp
  4. Fill the whole parent

Answer: B) As big as its content requires

Explanation: wrapcontent sizes the view to fit its content.

Discuss this question

22. Which resources scale perfectly to any density without multiple copies?

  1. JPG files
  2. PNG files in drawable-mdpi only
  3. GIF files
  4. Vector drawables

Answer: D) Vector drawables

Explanation: Vector drawables are resolution-independent.

Discuss this question

23. Which state is saved AUTOMATICALLY on rotation?

  1. A counter stored in a variable
  2. All member variables
  3. The text of an EditText that has an ID
  4. Data downloaded from the internet

Answer: C) The text of an EditText that has an ID

Explanation: Framework views with IDs save their own state.

Discuss this question

24. Which widget lets the user pick one option from a drop-down list?

  1. CheckBox
  2. SeekBar
  3. Spinner
  4. ImageView

Answer: C) Spinner

Explanation: A Spinner shows a drop-down selection.

Discuss this question

25. In a horizontal LinearLayout, two buttons with width 0dp and weights 1 and 2 share the width in the ratio:

  1. 1 : 2
  2. 2 : 1
  3. 1 : 1
  4. 0 : 3

Answer: A) 1 : 2

Explanation: Weights distribute remaining space proportionally.

Discuss this question

Page 1 of 2 Next

Practise Screen Components and Orientation MCQs

More Computer Science chapters