Pass the Google Google Developers Certification Associate-Android-Developer Questions and answers with CertsForce

Viewing page 2 out of 4 pages
Viewing questions 11-20 out of questions
Questions # 11:

What is demonstrated by the code below?

// RawDao.kt

@Dao

interface RawDao {

@RawQuery

fun getUserViaQuery(query: SupportSQLiteQuery?): User?

}

// Usage of RawDao

...

val query =

SimpleSQLiteQuery("SELECT * FROM User WHERE id = ? LIMIT 1",

arrayOf(sortBy))

val user = rawDao.getUserViaQuery(query)

...

Options:

A.

A method in a Dao annotated class as a raw query method where you can pass the query as a

SupportSQLiteQuery.


B.

A method in a Dao annotated class as a query method.


C.

A method in a RoomDatabase class as a query method.


Questions # 12:

LiveData.postValue() and LiveData.setValue() methods have some differences. So if you have a following code executed in the main thread:

liveData.postValue("a"); liveData.setValue("b");

What will be the correct statement?

Options:

A.

The value "b" would be set at first and later the main thread would override it with the value "a".


B.

The value "a" would be set at first and later the main thread would override it with the value "b".


C.

The value "b" would be set at first and would not be overridden with the value "a".


D.

The value "a" would be set at first and would not be overridden with the value "b".


Questions # 13:

In a class PreferenceFragmentCompat. What method is called during onCreate(Bundle) to supply the preferences for this fragment. And where subclasses are expected to call setPreferenceScreen (PreferenceScreen) either directly or via helper methods such as addPreferencesFromResource (int)?

Options:

A.

onCreateLayoutManager


B.

onCreatePreferences


C.

onCreateRecyclerView


D.

onCreateView


Questions # 14:

What is the incorrect statement about Data Access Object (androidx.room.Dao)?

Options:

A.

Data Access Objects are the main classes where you define your database interactions. They can include a variety of query methods.


B.

The class marked with @Dao should either be an interface or an abstract class. At compile time, Room will

generate an implementation of this class when it is referenced by a Database.


C.

An abstract @Dao class can optionally have a constructor that takes a Database as its only parameter.


D.

It is recommended to have only one Dao class in your codebase for all tables.


Questions # 15:

To create a basic JUnit 4 test class, create a class that contains one or more test methods. A test method begins with the specific annotation and contains the code to exercise and verify a single functionality in the component that you want to test. What is the annotation?

Options:

A.

@RunWith


B.

@LargeTest


C.

@Rule


D.

@Test


Questions # 16:

The following code snippet shows an example of an Espresso test:

Options:

A.

@Rule

fun greeterSaysHello() {

onView(withId(R.id.name_field)).do(typeText("Steve"))

onView(withId(R.id.greet_button)).do(click())

onView(withText("Hello Steve!")).check(matches(isDisplayed()))

}


B.

@Test

fun greeterSaysHello() {

onView(withId(R.id.name_field)).perform(typeText("Steve"))

onView(withId(R.id.greet_button)).perform(click())

onView(withText("Hello Steve!")).check(matches(isDisplayed()))

}


C.

@Test

fun greeterSaysHello() {

onView(withId(R.id.name_field)).do(typeText("Steve"))

onView(withId(R.id.greet_button)).do(click())

onView(withText("Hello Steve!")).compare(matches(isDisplayed()))

}


Questions # 17:

Interface for a callback to be invoked when a shared preference is changed. Interface is named:

Options:

A.

android.content.SyncStatusObserver


B.

android.content.SharedPreferences.Editor


C.

android.content.SharedPreferences.OnSharedPreferenceChangeListener


D.

android.content.SharedPreferences


Questions # 18:

Filter logcat messages. If in the filter menu, a filter option “Edit Filter Configuration”? means:

Options:

A.

Display the messages produced by the app code only (the default). Logcat filters the log messages using the PID of the active app.


B.

Apply no filters. Logcat displays all log messages from the device, regardless of which process you selected.


C.

Create or modify a custom filter. For example, you could create a filter to view log messages from two apps at the same time.


Questions # 19:

If you want to access a specific UI component in an app, use the UiSelector class. This class represents a query for specific elements in the currently displayed UI. What is correct about it? (Choose two.)

Options:

A.

If more than one matching element is found, the first matching element in the layout hierarchy is returned as the target UiObject.


B.

If no matching UI element is found, an IOException is thrown.


C.

If more than one matching element is found, the last matching element in the layout hierarchy is returned as the target UiObject.


D.

If no matching UI element is found, a UiAutomatorObjectNotFoundException is thrown.


Questions # 20:

What public methods are there in android.widget.Toast.Callback? (Choose two.)

Options:

A.

onDismissed()


B.

onToastHidden()


C.

onShown()


D.

onToastShown()


E.

onToastCancelled()


Viewing page 2 out of 4 pages
Viewing questions 11-20 out of questions