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: Imports a library Creates a new ID named btnSave in the R class Sets the button colour 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: View Bundle Service 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: xhdpi mdpi xxxhdpi 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? FrameLayout LinearLayout ConstraintLayout 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? Build.ORIENTATION resources.configuration.orientation == Configuration.ORIENTATIONLANDSCAPE window.isLandscape() 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? In onDestroy() In onPause() In onCreate(savedInstanceState) or onRestoreInstanceState() 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? It only works on tablets It slows the emulator It is not allowed in XML 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: A weight Four margins One horizontal and one vertical constraint 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? Intent Fragment ViewModel 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: AbsoluteLayout RelativeLayout ConstraintLayout TableLayout Answer: C) ConstraintLayout
Explanation: ConstraintLayout allows complex layouts with a flat hierarchy.
Discuss this question
36. Text sizes should use sp because sp: Is a physical millimetre Works only in landscape Is smaller than dp 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: res/layout-land res/landscape res/values-land/layout 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? LinearLayout TableLayout FrameLayout 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? Changing the device language Clicking a button Scrolling a list 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? Spinner FrameLayout Toolbar 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