Kotlin and Android From Scratch

Ace your homework & exams now with Quizwiz!

In Android, a graphic that can be drawn to the screen is generally referred to as a

Drawable

You should execute time-consuming tasks and I/O requests in your Activity/Fragment. - True - False

False

In the URL https://google.com/search?q=android, '/search' is called the _______ - Host - Path - Query - Parameters

Path

(Fill-in-the-blanks) Enter one or more words to complete the sentence. Before running the below code, simpleList should be initialized as a _______ list. println(simpleList) simpleList.add(-5) simpleList.remove(4) println(simpleList)

mutable

Match the element of HTTP requests and responses to the correct term. (Each answer only matches one item) Requests: Status Messages, Status Code, HTTP Verb, Content-Type Responses: POST, 200, OK, application/json

Status Message -> OK Status Code -> 200 HTTP Verb -> POST Content-Type -> application/json

Which of the following is true about class inheritance? - Class inheritance lets you reuse code and makes your program easier to maintain. - Properties and functions of the parent class(es) are available to the child class. - You can define additional properties and functions that are specific to subclasses. - You can override parent class members in subclasses. - All of the above

All of the Above

Using a data binding layout expression, what's the correct syntax for adding an attribute to the button in this layout in order to bind a click listener to it? <Button android:id="@+id/next_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/next" /> - android:onClick="@{detailFragment.next()}" - android:onClick="@{(Int) -> detailFragment()}" - android:click="@{() -> detailFragment.next()}" - android:onClick="@{() -> detailFragment.next()}"

android:onClick="@{() -> detailFragment.next()}"

(Fill-in-the-blanks) Enter one or more words to complete the sentence. In the below code, should be written in the for loop, so that the output returned is the list of numbers 1 through 3, with each number printed on a new line. val numbers = listOf(1, 2, 3) for (_______) { println(num) }

num in numbers

Which of the following statements about a conditional statement is true? (Choose as many answers as you see fit) - A conditional statement is a way for you to set up a condition and ensure that code following it is only executed if that condition is met. - A conditional statement does not require any keywords. - A conditional statement should only be used with integers as input. - A conditional statement can be used within functions to return output based on conditions defined in that function.

- A conditional statement is a way for you to set up a condition and ensure that code following it is only executed if that condition is met. - A conditional statement can be used within functions to return output based on conditions defined in that function.

Which of the following is an example of a "constraint" that could be applied to a view in a ConstraintLayout ViewGroup in the Layout Editor? (Choose as many answers as you see fit) - A view that must always be a minimum distance away from the edge of its container - A view that must always be free of warning triangles - A view that must always be to the right of another view - A view that must always be the topmost view inside a container - A view that must always include a contentDescription attribute

- A view that must always be a minimum distance away from the edge of its container - A view that must always be to the right of another view - A view that must always be the topmost view inside a container

Which of the following are needed to make a network request with Retrofit? (Choose as many answers as you see fit) - Add the android.permission.INTERNET permission to the manifest - Include Retrofit Gradle dependency - Supply a base URL to the Retrofit.Builder object, - Add coil library as a Gradle dependency.

- Add the android.permission.INTERNET permission to the manifest - Include Retrofit Gradle dependency - Supply a base URL to the Retrofit.Builder object,

Which of the following are true about binding adapters? (Choose as many answers as you see fit) - A binding adapter only provides an alternate way to set a hardcoded value. - Binding adapters allow you to implement custom logic for how layout attributes are assigned. - The @BindingAdapter annotation requires the view as an argument - @BindingAdapter methods process custom values that are provided to XML attributes.

- Binding adapters allow you to implement custom logic for how layout attributes are assigned. - @BindingAdapter methods process custom values that are provided to XML attributes.

In the fragment lifecycle, which of the following tasks should be performed in onViewCreated()? (Choose as many answers as you see fit) - Inflating the layout - Binding view objects to properties in your fragment - Configuring the options menu - Setting properties of individual views, such as a recycler view's adapter

- Binding view objects to properties in your fragment - Setting properties of individual views, such as a recycler view's adapter

Which of the following are true about grid layouts? (Choose as many answers as you see fit) - By default, a grid layout scrolls vertically - A grid layout is ideal for lists that can be represented as icons or images - A span is equal to the width of one row - You can reference the object by its type name, DataProviderManager.

- By default, a grid layout scrolls vertically - A grid layout is ideal for lists that can be represented as icons or images - You can reference the object by its type name, DataProviderManager.

Which of the following tasks can be performed in onCreate() (Choose as many answers as you see fit) - Configuring views, such as setting the layout manager of a recycler view. - Determining the items to be shown in the options menu. - Setting the onClickListener for items in the options menu. - Getting extras from the intent that launched the activity.

- Configuring views, such as setting the layout manager of a recycler view. - Getting extras from the intent that launched the activity.

Which of the following are Kotlin data types? (Choose as many answers as you see fit) - IntRange - Num - Int - Boolean (true or false)

- IntRange - Int - Boolean (true or false)

Which of the following are advantages of using Android Studio? (Choose as many as you seem fit) - It can help prevent typos and other mistakes in your code. - It comes with a virtual device called an emulator that can run your app. - It can show you a real-time preview of how your app will look on-screen while you code. - It can automatically translate your app into other languages.

- It can help prevent typos and other mistakes in your code. - It comes with a virtual device called an emulator that can run your app. - It can show you a real-time preview of how your app will look on-screen while you code.

In Android Studio, what is a project template good for? (Choose as many answers as you see fit) - It causes Android Studio to download files faster. - It makes getting started on building a new app faster. - It provides a structure that follows best practices. - It is the only way to build apps that can be previewed in Android Studio. - It makes building a new app less error-prone by pre-populating the project with some app code.

- It makes getting started on building a new app faster. - It provides a structure that follows best practices. - It makes building a new app less error-prone by pre-populating the project with some app code.

Why use the Material Components for Android library? (Choose as many answers as you see fit) - It provides widgets that follow the Material Design guidelines such as text fields and switches. - It makes your code compile faster. - It provides default Material themes that you can use directly or extend and then customize. - It automatically suggests ways for your app to look better. - It helps you more quickly build beautiful user experiences.

- It provides widgets that follow the Material Design guidelines such as text fields and switches. - It provides default Material themes that you can use directly or extend and then customize. - It helps you more quickly build beautiful user experiences.

Which line(s) of XML code will produce an error? <TextView2 android:layout_width="wrap_content" android:layout_height"wrap_content" android:padding="8dp" android:text="@string/title" android:textSize=18sp /> (Choose as many answers as you see fit) - Line 1 - Missing closing tag > after <TextView. - Line 3 - Missing = symbol after android:layout_height attribute. - Line 4 - The android:padding attribute does not exist for a TextView. - Line 5 - Use @str/title to refer to a string resource. - Line 6 - Missing quotations around the attribute value 18sp.

- Line 3 - Missing = symbol after android:layout_height attribute. - Line 6 - Missing quotations around the attribute value 18sp.

Which of the below steps are part of changing the color of your app theme? (Choose as many answers as you see fit) - Modify the themes.xml (night) file. - Set the primary and secondary color theme attributes of your app theme. - Define the colors used in your app as color resources in the colors.xml file. - Set the background color of your app in the activity's layout file. - Set the color attribute on all your UI components. - Change the name of your theme to your preferred color.

- Modify the themes.xml (night) file. - Set the primary and secondary color theme attributes of your app theme. - Define the colors used in your app as color resources in the colors.xml file.

Which of the following is an example of a class? (Choose as many answers as you see fit) - A Car class that has a make and model, and that can be driven - A Flower class that has a scent - A Puppy class that has breed, weight and age, and that can bark - A ShoppingCart class that has a cart size and cart value, and that can hold items - A Song class that has lyrics - None of these are examples of a class.

- A Car class that has a make and model, and that can be driven - A Flower class that has a scent - A Puppy class that has breed, weight and age, and that can bark - A ShoppingCart class that has a cart size and cart value, and that can hold items - A Song class that has lyrics

Which of the following are reasons to use a ViewModel? (Choose as many answers as you see fit) - A ViewModel and its data can survive orientation changes in an Activity/Fragment. - A ViewModel allows you to separate code that updates the UI from code that doesn't need to rely on the UI or its lifecycle. - A ViewModel prevents your data from updating the UI automatically.

- A ViewModel and its data can survive orientation changes in an Activity/Fragment. - A ViewModel allows you to separate code that updates the UI from code that doesn't need to rely on the UI or its lifecycle.

What is the purpose of the activity_main.xml file in the project you created? - It provides the theme settings for your app - It lets your app users create their own custom views of the app - It stores all the images your app will use - It describes the layout of view groups and views for a screen

It describes the layout of view groups and views for a screen.

What do you expect this Kotlin code to do? fun main(args: Array<String>) { println("Hello, world!") println("It's a sunny and warm day!") } - Print one line of text - Print two lines of text - Print three lines of text - Print two lines of text seperated by a blank line

Print two lines of text

What is the correct way to access the shared view model using the Kotin property delegate approach? - val viewModel: OrderViewModel by viewModels() - val viewModel: OrderViewModel by activityViewModels() - val viewModel: OrderViewModel by sharedViewModels() - val viewModel: OrderViewModel by fragmentViewModels()

val viewModel: OrderViewModel by activityViewModels()

What is responsible for determining which thread is used behind the scenes by a coroutine? - CoroutineScope - Dispatcher - Job - GlobalScope

Dispatcher

(True or False) A Job is a cancelable unit of work performed by a coroutine.

True

Which of the following are true about abstract classes? (Choose as many answers as you see fit) - They can be extended by subclasses and implementations can be provided for abstract members of the class. - They have an implementation for all of their properties and functions. - They may have abstract properties or abstract functions. - They can be instantiated. - They are not fully implemented and cannot be instantiated. - They need to be marked with the open keyword to be extended.

- They can be extended by subclasses and implementations can be provided for abstract members of the class. - They may have abstract properties or abstract functions. - They are not fully implemented and cannot be instantiated.

Which of the following are required to load and display an image with coil? (Choose as many answers as you see fit) -A placeholder image -An error image -The URL of the image -An ImageView

-The URL of the image -An ImageView

Class or Instance? Information about properties shared by all "things" belonging to the class, such as number of sides, number of legs, or that it has a color.

Class

The type of ViewGroup that helps you arrange the views inside of it in a flexible way is called a

ConstraintLayout

What does IDE stand for? - Integrated Development Environment - Independent Design Environment - Ideal Developer Environment - Intelligent Design Environment

Integrated Development Environment

Which of the following is false about collections and higher order functions in Kotlin? - Lists, maps, and sets can all use higher order functions. - Lists are unordered, while maps and sets are ordered data types. - Like the elements in a set, the keys in a map must be unique. However, multiple keys can map to the same value. - Higher order functions such as map and filter can take lambda functions as parameters.

Lists are unordered, while maps and sets are ordered data types.

onCreateView() is only called once for a fragment's entire lifecycle. - True - False

False

Which of the following is true about Gradle? (Choose as many answers as you see fit) - Gradle is an automated build system used by Android Studio to build your apps. - Gradle handles installing your app on a device. - Your app's build.gradle file is written in XML. - You can configure Android-specific options for your project in your app's build.gradle file. - The gradle configuration for your project cannot change after you initially create the project.

- Gradle is an automated build system used by Android Studio to build your apps. - Gradle handles installing your app on a device. - You can configure Android-specific options for your project in your app's build.gradle file.

Why should you use string resources instead of hard-coded strings in your apps? (Choose as many answers as you see fit) - It makes your app easier to translate - It allows you to use longer strings in your app - It allows you to apply special color attributes to your string - It allows you to reuse the same string in multiple places in your program

- It makes your app easier to translate. - It allows you to reuse the same string in multiple places in your program.

Which of the following are advantages to using RecyclerView (Choose as many answers as you see fit) - RecyclerView comes with built-in layout managers. - RecyclerView lets you use packages to organize your code. - RecyclerView helps save processing time, which can help scrolling through a list smoother. - RecyclerView is designed to be efficient for lists by reusing views that have scrolled off the screen. - RecyclerView automatically incorporates Material Design components.

- RecyclerView comes with built-in layout managers. - RecyclerView helps save processing time, which can help scrolling through a list smoother. - RecyclerView is designed to be efficient for lists by reusing views that have scrolled off the screen.

Which of the following are characteristics of a RESTful service? (Choose as many answers as you see fit) - Stateless - JSON responses - Client-server-architecture - Resources exposed as URIs

- Stateless - Client-server-architecture - Resources exposed as URIs

Why does a RecyclerView need an Adapter? -To adapt data to display on a specific device type -To create a new ViewGroup - To adapt data from a data source into JSON - To create new ViewHolders and bind data to them

- To create new ViewHolders and bind data to them

Which of the following is true about packages? (Choose as many answers as you see fit) - You can use packages to organize your code. - In order to use a class from another package, you have to explicitly import it in your code. - The package name is usually structured from specific to general. - It is good practice to use packages to group classes by functionality.

- You can use packages to organize your code. - In order to use a class from another package, you have to explicitly import it in your code. - It is good practice to use packages to group classes by functionality.

Which of the following is true about coroutines? - Once started, a coroutine cannot be canceled. - A coroutine always runs on the main thread. - A coroutine may or may not execute. - Coroutines avoid the need to create new threads, by running every task on the same thread.

A coroutine may or may not execute.

What is a program - A specific task - A tool that helps you write Kotlin code - A series of instructions that a computer system executes to accomplish some action - A defined set of instructions that tells your computer to print "Happy Birthday!"

A series of instructions that a computer system executes to accomplish some action

What is a good reason for you to add comments to your code? - To explain to yourself or others why the code is written a certain way. - To structure code, like chapter headings in books - To point out some part of the code that is very important - To explain to other developers how to use your code for their own programs - All of the above - None of the above

All of the Above

Which of the following elements is considered a View in an Android app? - An image - A clickable button - Text on the screen - All of the above - None of the above

All of the above

Which of the following is false about intents? - Both implicit and explicit intents allow your app to launch another activity. - Explicit intents require you to specify the class of the activity you want to show. - Intents are performed using the startActivity() method. - An implicit intent always results in the system asking the user which app to open.

An implicit intent always results in the system asking the user which app to open.

How do you create a new project in Android Studio? - A. Log out of Android Studio, and navigate to your project folder to find instructions. - B. If you have a project already open, select File > New > New Project from the Android Studio menu. - C. In the "Welcome to Android Studio" window, click "Start a new Android Studio project." - D. Create a new file on your computer, and title it "New Android Studio Project." - Both B and C are ways to create a new project in Android Studio. Correct! - None of the above

Both B and C are ways to create a new project in Android Studio. Correct!

The ________ is called when you create an instance of a class.

Constructor

Fill-in-the-blanks (Enter one or more words to complete the sentence) A ______ is similar to a promise or future in other languages and serves as a placeholder for a return value.

Deffered

(True or False) In most apps, you would create coroutines using the global scope.

False

It's OK for a ViewModel to directly reference a View or LifecycleOwner class. - True - False

False

In the fragment lifecycle, which of the following tasks should be performed in onCreateView()? - Inflating the layout - Binding view objects to properties in your fragment - Configuring the options menu - Setting properties of individual views, such as a recycler view's adapter

Inflating the layout

Class or Instance? The specifics about a property, such as the specific color of a "thing" that can have a color.

Instance

What is the main purpose of a ViewGroup? - It groups together the most common views that developers use in Android apps. - It serves as a container for View objects, and is responsible for arranging the View objects within it. - It is required to make a view interactive as a way to group TextViews on a screen. - It is required to set colors and background images.

It serves as a container for View objects, and is responsible for arranging the View objects within it.

Fill-in-the-blanks (Enter one or more words to complete the sentence) The ______ thread, sometimes called the UI thread, is responsible for updating the screen in an Android app.

Main

How would you modify this main() function so that it prints a 6-layer cake for someone's 4th birthday? fun main() { val age = 24 val layers = 5 printCakeCandles(age) printCakeTop(age) printCakeBottom(age, layers) } - Set val age to 6, set val layers to 4 - Set val age to "4", set val layers to "6" - Set val age to 4, set val layers to 6 - Leave the code as-is

Set val age to 4, set val layers to 6

An activity contains the following code in onCreate(). What will happen when this code is executed, if the intent property is null? val message = intent.extras?.getString("message").toString() - The app will crash because it attempted to access the extras property on a null object. - The app will crash because it attempted to access a null object. - The app will not crash because the extras property is accessed unsafely using '?' - The app will not crash because the extras property is accessed safely using '?'

The app will crash because it attempted to access the extras property on a null object.

What does "Minimum SDK" refer to in an Android Studio project? - The minimum amount of storage that your app requires for download - The minimum number of devices that your app can access - The minimum download speed that your app requires - The minimum version of Android that your app can run on

The minimum version of Android that your app can run on

(Fill-in-the-blanks) Enter one or more words to complete the sentence. Use a LiveData _________ to return a different LiveData instance based on the value of another instance.

Transformation

Which keyword do you use to define a function in Kotlin? - fun - func - function - newFunction - main

fun

If you open an app, and then leave the app using the back button, in which order were the following activity lifecycle methods called? - onStart(), onCreate(), onDestroy(), onStop() - onDestroy(), onStart(), onCreate(), onStop() - onCreate(), onStart(), onStop(), onDestroy() - onStart(), onCreate(), onStop(), onDestroy()

onCreate(), onStart(), onStop(), onDestroy()

Which activity lifecycle method would be called if a dialog appears onscreen, partially obscuring an activity? - onPause() because the activity is still displayed, but no longer has focus. - onStop() because the activity does not need to respond to user input while the dialog is onscreen. - onResume() because the activity needed to respond to user input to display the dialog. - onDestroy() because the activity does not need to exist so long as it doesn't have focus.

onPause() because the activity is still displayed, but no longer has focus.

(Fill-in-the-blanks) Enter one or more words to complete the sentence. The ________ method needs to be overridden in the host activity to ensure your app's fragment-based navigation responds to the app's "Up" button.

onSupportNavigateUp()

Which of the following is NOT a way for creating a comment in Kotlin? (Choose as many answers as you see fit) - Add // at the beginning of or inside a line and anything after that // is considered a comment. - Put /* or /** to start a block comment, and end it with */. - Use // to turn the rest of a function into a comment. - Use /* to start a comment that is one line long.

- Use // to turn the rest of a function into a comment. - Use /* to start a comment that is one line long.

In which method should you handle what happens when a button in the app bar is pressed? - onCreateOptionsMenu() - openOptionsMenu() - onOptionsItemSelected() - onPrepareOptionsMenu()

- onOptionsItemSelected()

Which of the following is true about the lifecycle of a single activity (Choose as many answers as you see fit) - onStart() can be called multiple times, while onCreate() can only be called once. - onStop() can be called multiple times, while onPause() can only be called once. - onDestroy() is called when the app enters the background. - onResume() is called when the activity gains focus.

- onStart() can be called multiple times, while onCreate() can only be called once. - onResume() is called when the activity gains focus.

Which of the following statements are valid? (Choose as many answers as you see fit) - val list = listOf(1, 2, 5) - val oddNumbers = mutableListOf("1", "9", "15") - val listValues: MutableList<Boolean> - val fruits = list("apple", "banana", "pear") - val words: List<String> = listOf("jump", "run", "skip")

- val list = listOf(1, 2, 5) - val oddNumbers = mutableListOf("1", "9", "15") - val listValues: MutableList<Boolean> - val words: List<String> = listOf("jump", "run", "skip")

Which of the following are some of the pitfalls of directly using threads in your code? (Choose as many answers as you see fit) -Race conditions -Inconsistent output -Unresponsive UI -Thread is deprecated

-Race conditions -Inconsistent output -Unresponsive UI

Which of the following is a benefit of using fragments? - Navigation between fragments allows for more sophisticated user interface patterns, such as tab bars. - Using multiple fragments within an activity allows for an adaptive layout across multiple screen sizes. - The same fragments can be reused across multiple activities. - All of the above

All of the above

Why should you initialize and store LiveData in your ViewModel instead of a UI Controller? - Both the ViewModel and LiveData are lifecycle aware. - To ensure that the LiveData isn't destroyed when the UI Controller is destroyed. - To hide or separate implementation details making your app more flexible. - All of the above

All of the above

True or false? Every MainActivity class in Android must have a main() function.

False

Given the code for navigating between two fragments in a note-taking app, a list of books and a list of notes, which of the following is true about the navigation graph file? val action = BooksListFragmentsDirections.actionBooksListToNotesList(bookIndex = index) holder.view.findNavController().navigate(action) A - Both the books list and notes list are destinations. B - The books list fragment has an argument called bookIndex. C - There's an action defined on the navigation graph that goes from the books list to the notes list. D - A, B, and C are true. E - Only A and C are true.

E - Only A and C are true.

How can the apply function in Kotlin be used to configure an object? - It can directly apply the object. - It can apply a set of assignments to the object. - It can apply new instances from the object. - It is not recommended to use apply to configure an object.

It can apply a set of assignments to the object.

The Moshi library requires the following to successfully process JSON in Kotlin. (Choose as many answers as you see fit) - A data class describing the structure of the JSON object. - KotlinJsonAdapterFactory() added to the Moshi.Builder object. - A MoshiConverterFactory added to the Retrofit.Builder object. - All properties in the data class marked with the @JSON annotation.

- A data class describing the structure of the JSON object. - KotlinJsonAdapterFactory() added to the Moshi.Builder object. - A MoshiConverterFactory added to the Retrofit.Builder object.

Which of the following statements about app icons are true? (Choose as many answers as you see fit) - It is sufficient to provide a single bitmap image of your app icon in your project to make it appear high quality on a range of Android devices. - mdpi, hdpi, xhdpi, xxhdpi, and xxxhdpi are density qualifiers for resource directories to indicate that these are resources to be used on devices with a specific screen density. - Adaptive icons are made up of a foreground and background layer, and an OEM mask will be applied on top of them. - Vector drawables only work for a certain screen density and should not be scaled.

- mdpi, hdpi, xhdpi, xxhdpi, and xxxhdpi are density qualifiers for resource directories to indicate that these are resources to be used on devices with a specific screen density. - Adaptive icons are made up of a foreground and background layer, and an OEM mask will be applied on top of them.

Which of the following are suspend functions? (Choose as many answers as you see fit) -async() -The lambda passed into async() -runBlocking() -The lambda passed into runBlocking()

-The lambda passed into async() -The lambda passed into runBlocking()

observe allows you to do which of the following for changes? - a LiveData object - any mutable object - any property in a ViewModel - any property in a ViewModel or LiveData object

A liveData object

Which of these options correctly calls the function, below, and passes it valid input arguments? fun createMessage(name: String, location: String, age: Int) { println("My name is ${name}. I am from ${location}, and I am ${age} years old.") } - createMessage("Amy", "Australia", 20) - createMessage("Evan", England, 9) - createmessage("Tom", "Thailand", "40") - createMessage(Heather, "Haiti", 7)

createMessage("Amy", "Australia", 20)

(Fill-in-the-blanks) Enter one or more words to complete the sentence. A(n) _________ is a piece of data passed between activities when launching an intent.

extra

Which of the following do you need to create a Kotlin program that prints a line of text? (choose as many answers as you see fit) - comment describing what your program does - a main() function - curly braces {} around the instructions to the system - a call to print() or println() - a piece of text surrounded by quotation marks

- a main() function - curly braces {} around the instructions to the system - a call to print() or println() - a piece of text surrounded by quotation marks

Which of the following are Attributes in Android? (Choose as many answers as you see fit) - text - textSize - textUse - textColor - textContent

- text - textSize - textColor

Which of the following are false about async() and runBlocking()? - Both functions take a CoroutineScope (a suspend function) as a parameter - Both functions return a Deferred - You'll typically not use runBlocking in Android app code - When using async, you need to use await() to access the returned value

Both functions return a Deferred

(True or False) If a function already calls a suspend function, then it does not need to be marked as a suspend function itself. True False

False

Given the following code, what is the result of oneWordCities[1]? val cities = listOf("Jeddah", "Bengaluru", "Shenzhen", "Abu Dhabi", "Mountain View", "Tripoli", "Bengaluru", "Lima", "Mandalay", "Tripoli") val oneWordCities = cities.toSet().toList().filter { !it.contains(" ") }.sorted() - Tripoli - Abu Dhabi - Jeddah - Bengaluru

Jeddah

What is the purpose of using a virtual device, or emulator, in Android Studio? - To show a variety of error messages to users - To experiment with app code safely - To test your app on a device without having that physical device - To see what your app looks like in a web browser

To test your app on a device without having that physical device

(True or False) Retrofit creates the code required to make network requests based on a web service

True

You can use the same ViewModel for multiple Activities or Fragments to share data. - True - False

True

How do you mark a property to be used only inside its current class? - Use the override keyword. - Use the val keyword. - Use the private keyword. - Use the closed keyword. - It is not possible to do this.

Use the private keyword

A ViewModel is destroyed after which of the following ? - always after onStop - always after onDestroy - after onDestroy, if it not a configuration change

after onDestroy, if it not a configuration change

Select all answers that are true for this XML layout when displayed on the screen. (You can sketch this out on a piece of paper first, if that helps.) <androidx.constraintlayout.widget.ConstraintLayout android:layout_width="match_parent"android:layout_height="match_parent"><TextView android:id="@+id/textViewA" android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="A" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> <TextView android:id="@+id/textViewB" android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="B" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toTopOf="parent" /> </androidx.constraintlayout.widget.ConstraintLayout> (Choose as many answers as you see fit) - TextView A appears vertically stacked on top of TextView B. - The starting edge of TextView A is aligned to the starting edge of the parent view. - The starting edge of TextView B is aligned to the starting edge of the parent view. - TextView B is horizontally and vertically centered within the parent. - The tops of TextView A and TextView B are aligned to top of the parent view. - The width of TextView A matches the width of the parent ConstraintLayout.

- The starting edge of TextView A is aligned to the starting edge of the parent view. - The tops of TextView A and TextView B are aligned to top of the parent view.

Why do you declare DataProviderManager with the object keyword? (Choose as many answers as you see fit) - To make this object a singleton - A shared object provides a convenient way to store state - You only need one instance of the object. - DataProviderManager is an object and not a class.

- To make this object a singleton - You only need one instance of the object.

What should you do to ensure that the correct type of resource ID is passed in to a constructor? - Use an Adapter to force the type. - Only use a stringResourceId or imageResourceId. - Use resource annotations. - Use a naming convention to pass the ID in the form R.<type>. - None of the above

- Use resource annotations.

Which of the following is a difference between a class and an instance? (Choose as many answers as you see fit) - You can think of a class as a blueprint and an instance as the actual "thing". - A class is like architectural plans for a bridge, and the Golden Gate bridge an instance of those plans. - A class is for defining categories of "things", while instances are for defining their properties. - You can create multiple instances from a class, but you can't create classes from instances.

- You can think of a class as a blueprint and an instance as the actual "thing". - A class is like architectural plans for a bridge, and the Golden Gate bridge an instance of those plans. - You can create multiple instances from a class, but you can't create classes from instances.

Which of the following is true about the lifecycle of a single activity (Choose as many answers as you see fit) - onStart() can be called multiple times, while onCreate() can only be called once. - onStop() can be called multiple times, while onPause() can only be called once. - onDestroy() is called when the app enters the background. - onResume() is called when the activity gains focus.

- onStart() can be called multiple times, while onCreate() can only be called once. - onResume() is called when the activity gains focus.

Which of the following are valid keywords used in conditional statements in Kotlin? (Choose as many answers as you see fit) - if, else - if, then, stop - when - repeat, finish

-if, else -when


Related study sets

Exam Chapter 22 The Lymphatic System & Immunity

View Set

Vistas 5th edition -Supersite (lesson5) Identificar

View Set

Unit 2: Part One of the Code: Duties to Clients and Customers

View Set

APUSH Vol. 1 to 1877 Ch. 12 The Second War for Independence and the Upsurge of Nationalism 1812-1824

View Set