COURSE 5: Create the User Interface in Android Studio QUIZ ANSWERS
Week 2: Building UI with Jetpack Compose
Meta Android Developer Professional Certificate
Complete Coursera Answers & Study Guide
Enroll in Coursera Meta Android Developer Professional Certification
Building UI with Jetpack Compose INTRODUCTION
Discover Jetpack in more depth and understand how composables are decorated with modifiers, how it handles state management, and how to better lay out composables based on Material Design guidelines
Learning Objectives
- Implement an interactive UI through event handling.
- Implement styling with modifiers.
- Explore how Compose manages state.
- Build a responsive UI with different layouts.
- .
SELF-REVIEW: ADD EVENTS AND STYLING
1. What was the name of the composable replaced by xxx defined in this exercise?
@Composable
fun xxx() {
Column {
WeeklySpecial()
MenuDish()
}
}
- MenuDish
- LowerPanel (CORRECT)
- BottomPanel
Correct! The Composable name was LowerPanel.
2. In this exercise, Image composable loads the image from drawable using __________.
- drawableResource()
- drawable using painterResource() (CORRECT)
- resource()
Correct! the composable function is used to add the routes for the for the NavHost.
3. In this exercise, which listener was used to perform an action after the button is clicked?
- onMouseListener
- onClickListener (CORRECT)
- onKeyListener
Correct! The onClickListener was used when button is clicked.
4. In Compose, each composable has an argument called a modifier.
- True (CORRECT)
- False
That’s correct. In Compose, each composable has an argument called a modifier, which is set when defining the modifier. Modifiers are, essentially, Kotlin objects.
5. In this video, the background color was applied to the Column because it is at the top in the hierarchy.
- True (CORRECT)
- False
Correct. The background color was applied to the Column because being at the top of the hierarchy, it will apply to all the items within it.
6. In this video, for adding the text property to a Text object, the stringResource() function is used.
- True (CORRECT)
- False
Correct. The stringResource() function is used to load the resource from the strings.xml file.
7. Your response to an event or executing a certain piece of code or a function when an event occurs is called ___________________.
- Handling the event (CORRECT)
- Augment composables
- Event
That’s correct. Your response to an event or executing a certain piece of code or a function when an event occurs is called handling the event.
KNOWLEDGE CHECK: MODIFIERS AND INTERACTIVITY
1. Which of these is true for modifiers?
- They change how a composable behaves or appears. (CORRECT)
- They change the container of a composable
- They must be provided for every composable
That’s right! Modifiers can alter the way a composable behaves or appears.
2. The composable argument that would replace xxxx in the code below is known as a:
fun SayHello(name: String) {
Text(
text = "Hey $name!",
xxxx = xxxx.padding(10.dp)
)
}
- Compose
- Modifier (CORRECT)
- Augmenter
That’s correct. In Compose, each composable has an argument called a modifier, which is set when defining the modifier.
3. What is the order of precedence for modifier chaining in Android UI Development?
- Layout, Themes, Widgets
- Widgets, Layout, Themes (CORRECT)
- Themes, Widgets, Layout
That’s correct. This is the order of modifier chaining.
4. What is the best way to handle an event in Android UI Development?
- Use a switch statement.
- Implement an OnClickListener interface. (CORRECT)
- Augment composables
That’s correct. The OnClickListener interface is an Android UI development tool that allows developers to attach a listener to a View object.
5. Which of these event modifiers is used when the app user presses a mouse button?
- Shift (CORRECT)
- Alt (CORRECT)
- Action
- Control (CORRECT)
- Meta (CORRECT)
That’s correct. This modifier is used to detect if the user is pressing the shift key.
That’s correct. This modifier is used to detect if the user is pressing the alt key.
That’s correct. This modifier is used to detect if the user is pressing the control key.
That’s correct. This modifier is used to detect if the user is pressing the meta key.
SELF-REVIEW: MANAGING STATE IN COMPOSE
1. In this exercise, the padding Modifier was used to properly space composables.
- True (CORRECT)
- False
Correct! The padding Modifier was used to properly space composables.
2. In this exercise, which callback was used to monitor the Text composable value change?
- OnValueChange (CORRECT)
- onValueUpdate
- onTextChange
Correct! The onValueChange callback is used to monitor any changes in text state.
3. In the exercise, how was the username and password retrieved from Text composable?
- using text property (CORRECT)
- using string property
- using field property
Correct! The text property was used to verify if the username and passwords are valid.
4. You can also preserve the state by saving relevant information in the memory but also on the disk, using file write ups or storage in a database. Check all that apply.
- Saving relevant information in the memory (CORRECT)
- Saving information on a disk (CORRECT)
- Saving information using file write ups (CORRECT)
- Saving information using a database (CORRECT)
Correct! You can also preserve the state by saving relevant information in the memory.
Correct! You can also preserve the state by saving relevant information on a disk.
Correct! You can also preserve the state by saving relevant information using file write ups.
Correct! You can also preserve the state by saving relevant information using a database.
5. Compose provides a special composable function called remember.
- True (CORRECT)
- False
That’s correct. Compose provides a special composable [1] function called remember.
6. When you start up your Little Lemon app and you run the composable functions you defined for the first time to produce the UI, it is called ________________.
- Composition (CORRECT)
- Recomposition
That’s correct. When you start up your Little Lemon app and you run the composable functions you defined for the first time to produce the UI, it is called Composition.
7. In this video, remember was replaced by rememberSaveable to prevent the state even after the orientation changes.
- True (CORRECT)
- False
Correct. remember was replaced by rememberSaveable to prevent the state even after the orientation changes.
8. ____________________ means that you should define your composable function in such a way that, if you need a similar user interface element in your UI, you should be able to simply recall the same composable but this time passing in the new parameters.
- Reusability (CORRECT)
- Stateful composable
That’s correct! Reusability means that you should define your composable function in such a way that, if you need a similar user interface element in your UI, you should be able to simply recall the same composable but this time passing in the new parameters.
KNOWLEDGE CHECK: MANAGING STATE
1. Not all ‘events’ in an Android app happen due to user interaction.
- True (CORRECT)
- False
That’s right! Most of the events happen due to user interaction within the app, but there are some events which occur without user intervention such as network connection lost, battery charge drop and download completion.
2. What does ‘Recomposition’ in Jetpack Compose allow developers to do?
- Write new code without editing existing code.
- Reuse existing code
- Refresh the UI whenever the data changes. (CORRECT)
That’s correct! In Compose the recreation of an app UI may happen frequently and is called ‘Recomposition’
3. In Jetpack Compose what does the mutableStateOf function create?
- State that can be changed over time. (CORRECT)
- A fixed state of data
- An immutable state of code
That’s correct. The mutableStateOf API helps to preserve the state across recompositions and the activity lifecycle.
4. A composable holding and modifying its state internally is called a ____________.
- Stateful Recomposition
- Stateless composable
- Stateful composable (CORRECT)
That’s correct. Stateful composable is a way of building user interfaces in Android that allows developers to define the state of their views and components.
5. What is the main purpose of State Hoisting in Android UI Development?
- To store and restore UI states during configuration changes
- To aid in debugging an application
- To improve the performance of an Android application (CORRECT)
That’s correct. State hoisting is a concept in Android UI development that allows developers to save and restore the state of their UI components.
SELF-REVIEW: BUILDING A RESPONSIVE LAYOUT
1. In this exercise, what are the supported orientations?
- horizontal
- landscape (CORRECT)
- portrait (CORRECT)
Correct! App supports both orientations portrait and landscape.
Correct! App supports both orientations portrait and landscape.
2. In this exercise device orientation was retrieved using configuration.landscape property.
- True
- False (CORRECT)
Correct! The device orientation was retrieved using configuration.orientation property.
3. In this exercise, how many layouts where used?
- three layouts
- two layouts (CORRECT)
- one layout
Correct! Two layouts are required – one for the orientation landscape and one for portrait orientation.
4. The scaffold is a customizable layout that provides support to add various UI structures and components.
- True (CORRECT)
- False
Correct! Scaffolds are customizable layouts that provide support to add various UI structures and components.
5. A ________________ is a parameter that can accept composable content as generic lambda.
- slot (CORRECT)
- stateless composable
That’s correct. A slot is a parameter that can accept composable content as generic lambda.
6. The state of the UI components in a scaffold can be held by _________________. It is a class in Compose.
- scaffold state (CORRECT)
- suspended function
That’s correct. The state of the UI components in a scaffold can be held by. It is a class in Compose.
Coursera Meta Android Developer Professional Certificate Answers and Study Guide
Liking our content? Then don’t forget to ad us to your bookmarks so you can find us easily!
Weekly Breakdown | Meta Study Guides | Back to Top
MODULE QUIZ: BUILDING UI WITH JETPACK COMPOSE
1. Modifiers can be used to define margins and padding in Jetpack Compose.
- True (CORRECT)
- False
That’s correct. Modifiers can be used to define margins and padding in Jetpack Compose.
2. What type of UI components can be created with Jetpack Compose?
- Buttons
- Text boxes
- Menus
- All of the above (CORRECT)
- None of the above
That’s correct. All these components can be created with Jetpack Compose.
3. Which of the following is true when using modifiers with layouts in Jetpack Compose?
- Modifiers can be used to completely replace the layout.
- Modifiers can be used to modify the behavior of the layout.
- Modifiers can be used to customize the appearance of the layout.
- Modifiers can be used to alter the size, position and other attributes of views. (CORRECT)
Correct! In Jetpack Compose, modifiers can be used to alter the size, position and other attributes of views.
4. When declaring a state with Jetpack Compose, which of the following is most important?
- Ensuring that the state is mutable.
- Making sure the state has a unique name.
- Ensuring that the state is immutable. (CORRECT)
- Making sure that the state is accessible in all functions.
That’s correct. Ensuring that the state is immutable is the most important.
5. What is a recommended approach to ensure that a UI survives configuration changes when using Jetpack Compose?
- Use the onSaveInstanceState() function to save the UI state.
- Manually recreate the UI on configuration changes.
- Use the remember{} function to save the UI state. (CORRECT)
- Use the rememberSavedInstanceState() function to save the UI state.
That’s correct, you can use the remember{} function to save the UI state.
6. What is a Bottom Sheet Scaffold?
- A UI pattern that provides a full screen overlay when triggered.
- A UI pattern that slides up from the bottom of the screen. (CORRECT)
- A UI pattern that provides a side-panel for navigating.
That’s correct. Scaffold provides the basic structure to build your app, with components such as a top Bottom Sheet Scaffold that can be used to navigate between different screens or display additional content or options.
7. What is Material Design?
- Material Design is a system for developing websites.
- Material Design is a framework for creating web applications.
- Material Design is a design system for developing UIs for Android applications. (CORRECT)
- Material Design is a language for programming mobile applications.
That’s correct. Material Design is a design system created by Google for developing UIs for Android, web, and iOS applications.
8. What type of orientations are supported Android UI development?
- Horizontal and Vertical (CORRECT)
- Portrait and Landscape
- Fullscreen and Minimized
- Landscape and Portrait
Horizontal and Vertical is the correct way to refer to an app’s orientation.
9. Which Jetpack Compose Material components can be implemented as built-in composables?
- Button
- TextField
- Slider
- Card
- All of the above (CORRECT)
- None of the above
That’s correct, they are all Material components that can be implemented as built-in composables.
10. What are UI Patterns?
- UI Patterns are algorithms used to compute the layout of an Android UI.
- UI Patterns are data structures used to represent UI elements in an Android UI.
- UI Patterns are reusable solutions to common user interface problems during Android UI building in Jetpack Compose.
- UI Patterns are components of an Android UI that can be reused. (CORRECT)
That’s correct! UI Patterns are reusable solutions for common user interface problems encountered when building an Android UI in Jetpack Compose.
Interactive CSS CONCLUSION
To be written
Subscribe to our site
Get new content delivered directly to your inbox.
Quiztudy Top Courses
Popular in Coursera
- Google Advanced Data Analytics
- Google Cybersecurity Professional Certificate
- Meta Marketing Analytics Professional Certificate
- Google Digital Marketing & E-commerce Professional Certificate
- Google UX Design Professional Certificate
- Meta Social Media Marketing Professional Certificate
- Google Project Management Professional Certificate
- Meta Front-End Developer Professional Certificate
Liking our content? Then, don’t forget to ad us to your BOOKMARKS so you can find us easily!