Chapter - II (K1 - Remembering)Â
Design Android UI Layout
What is the primary purpose of Android UI Layouts? a) To store data
b) To manage background processes
c) To define the visual structure of the app
d) To handle network connections
Answer: c) To define the visual structure of the app
How can you create a user interface in Android? a) By using only XML
b) By coding it all in Java
c) By combining XML and Java/Kotlin
d) By using a separate HTML file
Answer: c) By combining XML and Java/Kotlin
Where do you typically define the layout for an Android activity? a) In the AndroidManifest.xml file
b) In the layout XML file
c) In the Java/Kotlin source file
d) In the Gradle build file
Answer: b) In the layout XML file
Which layout is best for creating a simple linear arrangement of UI elements? a) RelativeLayout
b) ConstraintLayout
c) LinearLayout
d) FrameLayout
Answer: c) LinearLayout
Who is responsible for designing the user interface in an Android project? a) The project manager
b) The developers
c) The UI/UX designer
d) The database administrator
Answer: c) The UI/UX designer
Define the term "ViewGroup" in Android. a) A single UI element
b) A container for multiple views
c) A library of views
d) A type of database
Answer: b) A container for multiple views
List common types of Android layouts. a) LinearLayout, RelativeLayout, ConstraintLayout
b) DatabaseLayout, ServerLayout, ClientLayout
c) TextLayout, ImageLayout, VideoLayout
d) None of the above
Answer: a) LinearLayout, RelativeLayout, ConstraintLayout
When should you use a ConstraintLayout? a) For complex and flexible layouts
b) For simple linear arrangements
c) For full-screen activities only
d) When using only images
Answer: a) For complex and flexible layouts
Why is it important to consider device resolution when designing layouts? a) To save memory
b) To ensure the app runs faster
c) To provide a consistent user experience across devices
d) It is not important
Answer: c) To provide a consistent user experience across devices
Recall what attribute is used to set the width of a UI element in XML. a) layout_height
b) layout_width
c) view_size
d) element_width
Answer: b) layout_width
Select the correct method to retrieve a UI element in an activity. a) findViewById()
b) getElement()
c) retrieveView()
d) fetchView()
Answer: a) findViewById()
Tell how you can make a UI element invisible in XML.Â
a) android
="gone"
b) android
="true"
c) android
="true"
d) android
="off"
Answer: a) android
="gone"
Match the following layout attributes:
1.layout_width
2.layout_height
3.layout_margin
4.layout_gravity
a) Defines the vertical space around a view
b) Determines how the view is positioned
c) Specifies the width of the view
d) Specifies the height of the view
Answer: 1-c, 2-d, 3-a, 4-b
Omit which of the following is not a type of layout in Android. a) ScrollView
b) RelativeLayout
c) LinearLayout
d) LinkLayout
Answer: d) LinkLayout
Find the layout that allows scrolling for its child views. a) RelativeLayout
b) FrameLayout
c) ScrollView
d) LinearLayout
Answer: c) ScrollView
Activity Lifecycle
What is the first method called when an Android activity is created? a) onStart()
b) onCreate()
c) onResume()
d) onPause()
Answer: b) onCreate()
How does the Android system manage the activity lifecycle? a) Using callbacks
b) By direct control
c) Through user input
d) Automatically without any control
Answer: a) Using callbacks
Where do you typically define the behavior for the onPause() method? a) In the layout XML file
b) In the activity class
c) In the manifest file
d) In a separate configuration file
Answer: b) In the activity class
Which lifecycle method is called when the user navigates away from the activity? a) onStop()
b) onDestroy()
c) onResume()
d) onPause()
Answer: d) onPause()
Who is responsible for handling the activity lifecycle methods? a) The Android OS
b) The developers
c) The project manager
d) The UI/UX designer
Answer: b) The developers
Define the purpose of the onDestroy() method in an activity. a) To initialize resources
b) To release resources before the activity is destroyed
c) To display the user interface
d) To save user data
Answer: b) To release resources before the activity is destroyed
List the main lifecycle methods of an Android activity. a) onCreate(), onStart(), onResume(), onPause(), onStop(), onDestroy()
b) init(), run(), pause(), finish()
c) begin(), end(), restart()
d) start(), stop(), continue()
Answer: a) onCreate(), onStart(), onResume(), onPause(), onStop(), onDestroy()
When is the onResume() method called? a) When the activity is starting
b) When the activity comes back to the foreground
c) When the activity is being paused
d) When the activity is destroyed
Answer: b) When the activity comes back to the foreground
Why is it important to manage the activity lifecycle properly? a) To enhance performance and user experience
b) It is not important
c) To make the app look better
d) To reduce the app size
Answer: a) To enhance performance and user experience
Recall which lifecycle method allows you to save UI state. a) onPause()
b) onStop()
c) onCreate()
d) onDestroy()
Answer: a) onPause()
Select the method that is called when an activity is no longer visible to the user. a) onStop()
b) onPause()
c) onResume()
d) onCreate()
Answer: a) onStop()
Tell what happens during the transition from onStart() to onStop(). a) The activity is fully visible
b) The activity is in the foreground
c) The activity is not visible to the user
d) The activity is destroyed
Answer: c) The activity is not visible to the user
Match the following activity lifecycle methods:
1.onCreate()
2.onPause()
3.onStop()
4.onResume()
a) Prepares the activity for user interaction
b) Cleans up resources before the activity is destroyed
c) Restores activity visibility
d) Stops the activity's interactions
Answer: 1-a, 2-d, 3-b, 4-c
Omit which of the following methods is not part of the activity lifecycle. a) onDestroy()
b) onCreate()
c) onComplete()
d) onStart()
Answer: c) onComplete()
Find the method that is called to retrieve data when the activity resumes. a) onCreate()
b) onResume()
c) onStart()
d) onRestart()
Answer: b) onResume()