Mobile Apps Exam Prep Quiz

Which of the following variable declarations is valid?
Var hello: Int? = ""
String "hello" = hello
Val hello = "hello"
Hello: String = "hello
It is considered best practice to declare a variable that will not change using var instead of val.
True
False
Which of the following are valid ways to update a variable? Choose as many answers as you see fit.
Total++
Total - 1
Total--
Total = total + 1
In Kotlin, comments can be single or multi-line and are ignored by the compiler
True
False
Which of the following is not a data type in Kotlin?
String
Decimal
Int
Boolean
Float also represents a decimal, but is less precise than Double.
True
False
In Kotlin, the entry point of a program is the ___.
Print() statement
Val variable
Main() function
Return statement
Which of the following are true about function return values? Choose as many answers as you see fit.
If a function does not specify a return type, the return type is Unit.
A return value can be stored in a variable
Functions with a return type of Unit must include a return statement.
A return value's type must match the return type of a function
Which of the following are true about functions? Choose as many answers as you see fit.
Functions can take parameters, or variables as inputs
Function parameters are required to have default arguments.
When calling a function with parameters, the values passed in are called arguments.
Breaking up your code into separate functions makes your code easier to maintain.
With named arguments, you can change the order in which you pass arguments into a function.
True
False
What does IDE stand for?
Intergrated Development Environment
Independent Design Environment
Ideal Developer Envrionment
Intelligent Design Environment
Which of the following are advantages of using Android Studio? Choose as many answers as you see 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.
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
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.
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.
None of the above
The following code will print "Divisible by 5" if number is equal to 25.

if (number % 10 == 0) { 

  println("Divisible by 10") 

} else if (number == 5) { 

  println("Divisible by 5") 

True
False
Which of the following conditions are satisfied when x = 5? Choose as many answers as you see fit.
X == 5
X in 1..5
X is int
X % 5
Which is not a basic concept of object-oriented programming
Abstraction
Readability
Inheritance
Polymorphism
Which are the four visibility modifiers in Kotlin?
Public, private, protected, abstract
Static, override, internal, external
Private, protected, public, internal
Public, protected, static, internal
A(n) ____ defines properties or methods that a class needs to implement
Delegate
Generic type
Interface
Subclass
Which of the following is best represented by a nullable type?
The number of followers (0 or more) in social media app.
An optional profile picture.
A username that must be at least one character.
A unique ID given to every user.
The ____ operator allows you to call a method only if the object is non-null.
.
!!
?:
?.
Which is not true of functions in Kotlin?
A function can be changed to another data type, and vice versa.
A function can be returned from another function.
A function can take another function as a parameter.
A function has a data type, such as (Int) -> Unit.
Which of the following is a valid way to define a data class in Kotlin?
Data class Person(val name: String, val age: Int)
Class Person(val name: String, val age: Int): data
Class Person(val name: String, val age: Int)
Data class Person{val name: String, val age: Int}
When using generics, the generic data type goes inside ____.
[ ]
{ }
( )
< >
A(n) ____ class is useful when you have a fixed set of values.
Enum
Sealed
Data
Inherited
To create a list object that has the ability to change its size, you would call ____.
ModifiableListOf()
ImmutableListOf()
ListOf()
MutableListOf()
Given the following line of code, which of the following commands will print Blue?
Choose as many answers as you see fit.

val colors = listOf("Red", "Green", "Blue")
Println(colors[2])
Println(colors.get(2))
Println(colors.contains(2))
Println(colors.getOrDefaultValue(index = 2, defaultValue = 10))
The programming concept of a class that has only one instance is called a _____.
Uniqueness
Singleton
Mono-object
Lambda
Which of the following statements is true regarding sets and maps?
A set must contain distinct values and a map's keys must be distinct.
A set must contain distinct values and a map's keys can contain duplicates.
A set can contain duplicate values and a map's values can contain duplicate values.
A set can contain duplicate values and a map's keys must be distinct.
If you have a variable named records, which is a collection, to determine the number of items it contains, you can call ____.
Records.length
Records.quantity
Len(records)
Records.size
Which method on an Activity inflates the app's layout and makes its views available as objects?
OnCreate()
SetClickListener()
SetContentView()
Show()
Which view attribute do you use to set the width of a View so that it adjusts to fit the content?
Android:view_width="wrap"
Android:layout_width="wrap_content"
Android:layoud_height="wrap_content"
Android:layout_width="math_parent"
Which method changes the image resource for an ImageView in Kotlin code?
SetImageResource()
SetImageURI()
SetImage()
SetImageRes()
What does the lateinit keyword in a variable declaration indicate in Kotlin code?
The variable is never initialized.
The variable is only initialized at app runtime.
The variable is automatically initialized to null.
The variable will be initialized later. I promise!
Which Gradle configuration indicates the most recent API level your app has been tested with?
MinSdkVersion
CompileSdkVersion
TargetSdkVersion
TestSdkVersion
Which of the following is a ViewGroup?
EditText
LinearLayout
TextView
Button
Which of the following listed view hierarchies is not valid?
LinearLayout > TextView, TextView, ImageView
ScrollView > LinearLayout > TextView, Button, ScrollView, TextView
TextView > TextView, ImageView, ScrollView
ConstraintLayout > TextView, EditText, Button
Styles are resources defined in styles.xml. Using styles, you can define colors, fonts, text size, and many other characteristics of a view. True or False?
True, you can define these.
False, you cannot define these.
A View can contain any number of View or ViewGroup as its children. True or False?
True, View can contain any number of View or ViewGroup.
False, View can have exactly 1 child.
What is EditText a subclass of?
TextField
LinearLayout
TextView
Button
Which of the following visibility attribute values, if set on a view, makes it so the view is hidden and does not take up any space in the layout?
Visible
Invisible
Gone
Hide
Which one of the following statements is true about Button views?
A Button view is a ViewGroup.
You can only have three Button views per screen.
Button views are clickable, and on click, the attached click listener performs an action.
Button is an extension of ImageView.
In a ConstraintLayout, which of the following choices describes the constraints needed to keep a view in place during runtime?
Two horizontal constraints.
One vertical constraint.
At least one horizontal and one vertical constraint.
There is no need to constrain the view
Which of the following constraint types expands a view only as much as needed to fit its contents?
Wrap content
Match constraint
Fixed constraint
Baseline constraint
What are some benefits of using the Layout Editor in Android Studio? Choose as many answers as you see fit.
Drag and drop UI elements onto the screen with the visual design editor.
Edit view attributes
Test button click behavior and see how the app will respond
Select device type and size for the preview of your layout
Which of the following is not a reason for minimizing calls to findViewById()?
Every time findViewById() is called, it traverses the view hierarchy.
FindViewById() runs on the main or UI thread.
These calls can slow down the user interface.
Your app is less likely to crash.
Before running the below code, simpleList should beinitialized as a _____ list.
println(simpleList)
simpleList.add(-5)
simpleList.remove(4)
println(simpleList)
Int
Scrollable
Sorted
Mutable
Why does a RecyclerView need an Adapter?
To adapt data to display on a specific devive type
To create a new ViewGroup
To adapt data from a data source into JSON
To create a new ViewHolders and bind data to them
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 doff the screen.
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.
What should you do to ensure that the correct type of resource ID is passed into a contrsutctor?
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.
None of the above
Enter one or more words to complete the sentance.

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 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.

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
Enter on or more words to complete the sentence.
 
A(n) ____ is a piece of data passed between activities when launching an intent.
Extra
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(), onCreater(), 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 response 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.
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.
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 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 ?.
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.
In which method should you handle what happens when a button in the app bar is pressed?
OnCreateOptionsMenu()
OpenOptionsMenu()
OnOptionsItemSelected()
OnPrepareOptionsMenu()
True or False: onCreateView() is only called once for a fragment's entire lifecycle.
True
False
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
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
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 recycler view's adapter
With a NavHost, you must explicitly specify a starting screen
True
False
The _____ method removes one or more screens from the backstack.
PopToStartDestination()
PopBackStack()
PopComposable()
PopToBackStack()
In a multi-screen app, navigating to a new screen puts it on the bottom of the backstack.
True
False
Intent _____ contain additional data passed to an Intent.
Arguments
Extras
Parameters
Properties
Which of the following are true about the Back and Up buttons? Choose as many answers as you see fit.
The Back button is a system button
The up button is provided by the system at the bottom of the screen
The Back button is part of the AppBar
The Up button in the AppBar automatically navigates to the previous screen.
The Back button only appears if you use navigation.
The Up button can be shown or hidden, depending on the current screen.
To avoid losing data during a device-configuration change, you should save app data in which class?
ViewModel
LiveData
Fragment
Activity
A ViewModel should never contain any references to fragments, activities, or views, True or False?
True, it should never contain any references.
False, it should contain at least a reference to one of the above.
When is a ViewModel destoryed?
When the associated UI controller is destroyed and recreated during a devie-orientation change.
In an orientation change.
When the associated UI controller is finished (if it is an activity) or detached (if it is a fragment).
When the user pressed the Back button.
What is the ViewModelFactory interface for?
Instantiating a ViewModel object.
Retaining data during orientation changes.
Refreshing the data being displayed on the screen.
Receiving notifications when the app data is changed.
Which method is first called when the app no longer has focus?
OnPause()
OnStart()
OnCreate()
OnStop()
After _____, the app is no longer visible on screen.
OnPause()
OnStart()
OnCreate()
OnStop()
Use _____ to write a debug message. This method takes two arguments: the log tag and the log message.
Log.i()
Log.d()
Log.e()
Log.w()
The separation of concerns design principle states that the app should be divided into classes, each with separate responsibilities.
True
False
The UI is what the user sees, while the UI state is what the app says they should see
True
False
According to the recommended app architecture, each application should have at least the following two layers:
The domain layer and the data layer
The UI layer and the data layer
Repository layer and the UI layer
The domain layer and the UI layer
Unit tests are executed on an Android device or emulator
True
False
How do you indicate that a class represents an entity to store in a Room database?
Make the class extend DatabaseEntity.
Annotate the class with @Entity.
Annotate the class with @Database.
Make the class extend RoomEntity and also annotate the class with @Room.
The DAO (data access object) is an interface that Room uses to map Kotlin functions to database queries. How do you indicate that an interface represents a DAO for a Room database?
Make the interface extend RoomDAO
Make the interface extend EntityDao, them implement the DaoConnection() method.
Annotate the interface with @Dao
Annotate the interface with @RoomConnection
Which of the following annotations can you use in your @Dao interface? Choose all that apply. Choose as many as you see fit.
@Get
@Update
@Insert
@Query
Which of the following is not a benefit of using coroutines?
They run asynchronously
They can be run on a thread other than the main thread.
They always make the app run faster.
They can use exceptions.
Which of the following is not true for Suspend functions?
A function annotated with the Suspend keyword.
A function that can be called inside coroutines.
While a Suspend functions is running, the calling thread is suspended.
Suspend functions must always run in the background.
Which of the following statements is NOT true?
When execution is blocked, no other work can be executed on the blocked thread.
When the execution is suspended, the thread can do other work while waiting for the offloaded work to complete.
Suspending is more efficient, because threads may not be waiting, doing nothing.
Whether blocked or suspended, execution is still waiting for the result of the coroutine before continuing.
Which of the following statements is not true about the @Query annotation?
The @Query annotation is used with a method in the DAO
The @Query annotation corresponds to a SELECT query.
The @Query annotation can pass arguments into a SQL statement by preceding their name with a colon.
The @Query annotation can only be used with a suspend function
Which of the following statements are true about the DAO?
DAO functions use annotations like @Insert and @Update that correspond to an operation on the database.
DAO functions can return a flow.
Instances of DAO classes are referenced in the AppDatabase class.
All of the above.
The Database class, inheriting from the RoomDatabase class, is responsible for_____.
Instantiating the database and providing access to the DAO.
Representing individual data tables.
Defining functions that map to SQL statements, such as SELECT queries.
Provides data to the UI.
The purpose of the DAO is to:
Hold reference to the view models and the database.
Define functions that map to SQL statements, such as SELECT, and INSERT queries.
Provide a factory method to create a database instance.
Create a new database instance
You can use the @Insert and @Delete annotations without providing a SQL statement
True
False
Enter one or more words to complete the sentence.
To handle conflicts when inserting into a database, you can pass a(n) _____ parameter, such as IGNORE, to the @Insert annotation.
OnConflict
Select all the statements that are true about the Database Inspector: Choose as many answers as you see fit.
It lets you inspect, query, and modify you app's databases while your app is running.
It works with other SQLite libraries that you bundle with your app.
It is especially useful for database debugging.
It works with plain SQLite and with libraries built on top of SQLite, such as Room.
Entities represent individual data tables in the Room database.
True
False
Which of the following statement is not true about the primary key:
You can use the primary key to uniquely identify every record/entry in your database tabled.
After you assign the primary key, you cannot modify it.
Room generates an incrementing primary key value for each entity by default.
The primary key represents the entity object as long as it exists in the database.
What are the two key things Retrofit needs to build a web services API?
The base URI for the web service, and a GET query.
The base URI for the web service, and a converter factory.
A network connection to the web service, and an authorization token.
A converter factory, and a parser for the response
How do you add a query option to a REST web service call in Retorfit?
Append the query to the end of the request URL.
Add a parameter for the query to the function that makes the request and annotate that parameter with @Query
Use the Query class to build a request.
Use the addQuery() method in the Retrofit builder.
With concurrent programming, code might execute in an order different from how it was written.
True
False
Enter one or more words to complete the sentence.
The ______ composable is used to respond to the Back button, with or without a NavHost.
BackHandler
Which of the following statements are true about coroutine contexts? Choose as many asnwers as you see fit.
Dispatchers.Default is the best choise for long running tasks involving reading and writing large amounts of data.
Dispatchers.Main can be used for updating the UI but not for long-running-tasks.
A Job controls the lifecycle of a coroutine.
Dispatchers.IO is optimized for network I/O, among other background tasks
Launch() and async() are extension functions of a ______, which keeps track of any coroutines it creates.
CoroutineScope
Job
Dispatcher
CoroutineContext
Which of the following statements are true about web services? Choose as many answers as you see fit.
GET, POST, and DELETE are all examples of HTTP operations.
A URL is a type of URI but not all URIs are URLs
RESTful services always provide a formatted XML response
Retrofit is a third-party library for handling JSON from a web service.
Retrofit is a third-party library that enables your app to make reuqests to a(n) ____ web service.
XML
Socket
RESTful
JSON
One recommended way to perform a Retrofit network request is with a coroutine launched in the viewModelScope.
True
False
To enable your app to make connections to the Internet, add the 'android.permission.INTERNET' permission in the ______ file.
MainActivity
Build.gradle
Android manifest
ViewModel
The process of turning a JSON result into usable data, as is done with Gson, is called JSON ______.
Serialization
Encoding
Converting
Parsing
Which of the following is not a common HTTP operation/method:
GET
POST
DELETE
SET
The response from a REST web service is commonly formatted in one of the common data transfer formats like XML or JSON.
True
False
Which of the following is not true for the Retrofit library:
It is a client library
It enables your app to make requests to a REST web service.
It converts Kotlin objects to JSON objects.
It is a third-party library
Which of the following applies to a Singleton pattern:
Object declarations are used to declare singleton objects in Kotlin.
Ensures that one, and only one, instance of an object is created
Has one global point of access to that object.
All of the above
Each JSON object contains the following:
A set of key-value pairs separated by a colon.
A set of key-value pairs separated by a comma.
A set of key-value pairs separated by a semi colon
None of the above
Following Android's recommended app architecture guidelines, an app should have which of the following:
A UI Layer
A Domain Layer
A Data Layer
A Business Layer
The advantages of using Dependency Injection (DI) in your app include which of the following: Choose as many answers as you see fit.
Helps with the reusability of code
Makes refactoring easier
Helps with testing
Makes your app run faster
If your app has more than one type of data source, they should all be stored in the same repository for ease of use.
True
False
Which of the following is used to replace the Main dispatcher with a TestDispatcher in a local unit test:
RunTest
RunBlocking
Dispatchers.resetMain()
Dispatchers.setMain()
The runTest() function can be used to test suspend functions.
True
False
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
Val fruits = list("apple", "banana", "pear")
Val words: List = listOf("jump", "run", "skip")
{"name":"Mobile Apps Exam Prep Quiz", "url":"https://www.quiz-maker.com/QPREVIEW","txt":"Which of the following variable declarations is valid?, It is considered best practice to declare a variable that will not change using var instead of val., Which of the following are valid ways to update a variable? Choose as many answers as you see fit.","img":"https://www.quiz-maker.com/3012/images/ogquiz.png"}
Powered by: Quiz Maker