MCQs / Computer Science / Screen Components and Orientation

Screen Components and Orientation MCQs — Computer Science (page 2)

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.

26. @+id/btnSave in XML:

  1. Imports a library
  2. Creates a new ID named btnSave in the R class
  3. Sets the button colour
  4. Refers to a string

Answer: B) Creates a new ID named btnSave in the R class

Explanation: The plus sign creates the ID if it does not exist.

Discuss this question

27. The basic building block of the Android UI that draws and handles events is a:

  1. View
  2. Bundle
  3. Service
  4. Intent

Answer: A) View

Explanation: All widgets extend android.view.View.

Discuss this question

28. The density bucket with a scale factor of 2× is:

  1. xhdpi
  2. mdpi
  3. xxxhdpi
  4. hdpi

Answer: A) xhdpi

Explanation: xhdpi (~320 dpi) is 2× mdpi.

Discuss this question

29. Which layout arranges children in a single row or column?

  1. FrameLayout
  2. LinearLayout
  3. ConstraintLayout
  4. TableLayout

Answer: B) LinearLayout

Explanation: LinearLayout uses orientation horizontal or vertical.

Discuss this question

30. Which code checks if the device is currently in landscape?

  1. Build.ORIENTATION
  2. resources.configuration.orientation == Configuration.ORIENTATIONLANDSCAPE
  3. window.isLandscape()
  4. display.rotation == 90 only

Answer: B) resources.configuration.orientation == Configuration.ORIENTATIONLANDSCAPE

Explanation: The current Configuration holds the orientation.

Discuss this question

31. Where is the saved Bundle received after recreation?

  1. In onDestroy()
  2. In onPause()
  3. In onCreate(savedInstanceState) or onRestoreInstanceState()
  4. In the manifest

Answer: C) In onCreate(savedInstanceState) or onRestoreInstanceState()

Explanation: The same Bundle is passed to onCreate and onRestoreInstanceState.

Discuss this question

32. Why should px be avoided for view sizes?

  1. It only works on tablets
  2. It slows the emulator
  3. It is not allowed in XML
  4. The same px value looks physically different on screens of different densities

Answer: D) The same px value looks physically different on screens of different densities

Explanation: Pixel sizes do not adapt to density.

Discuss this question

33. In ConstraintLayout every view needs at least:

  1. A weight
  2. Four margins
  3. One horizontal and one vertical constraint
  4. An ID only

Answer: C) One horizontal and one vertical constraint

Explanation: Without both constraints the view jumps to the top-left at run time.

Discuss this question

34. Which Jetpack class keeps UI data alive across configuration changes?

  1. Intent
  2. Fragment
  3. ViewModel
  4. Bundle

Answer: C) ViewModel

Explanation: ViewModel instances survive recreation of the activity.

Discuss this question

35. Google's recommended layout for flat, flexible and responsive screens is:

  1. AbsoluteLayout
  2. RelativeLayout
  3. ConstraintLayout
  4. TableLayout

Answer: C) ConstraintLayout

Explanation: ConstraintLayout allows complex layouts with a flat hierarchy.

Discuss this question

36. Text sizes should use sp because sp:

  1. Is a physical millimetre
  2. Works only in landscape
  3. Is smaller than dp
  4. Scales with the user's font-size preference

Answer: D) Scales with the user's font-size preference

Explanation: sp respects accessibility font scaling.

Discuss this question

37. A landscape-specific layout must be placed in:

  1. res/layout-land
  2. res/landscape
  3. res/values-land/layout
  4. res/layout/land

Answer: A) res/layout-land

Explanation: The -land qualifier marks landscape resources.

Discuss this question

38. Which layout stacks its children on top of each other?

  1. LinearLayout
  2. TableLayout
  3. FrameLayout
  4. GridLayout

Answer: C) FrameLayout

Explanation: FrameLayout overlays children; useful for a single child or containers.

Discuss this question

39. Which of these is a configuration change?

  1. Changing the device language
  2. Clicking a button
  3. Scrolling a list
  4. Receiving a Toast

Answer: A) Changing the device language

Explanation: Orientation, locale, keyboard, dark mode and screen size changes are configuration changes.

Discuss this question

40. Which container makes a long form scroll vertically?

  1. Spinner
  2. FrameLayout
  3. Toolbar
  4. ScrollView

Answer: D) ScrollView

Explanation: ScrollView adds vertical scrolling to its single child.

Discuss this question

Previous Page 2 of 2

Practise Screen Components and Orientation MCQs

More Computer Science chapters