Google Associate Android Developer ASSOCIATE ANDROID DEVELOPER Exam Questions in PDF

Free Google ASSOCIATE ANDROID DEVELOPER Dumps Questions (page: 2)

Android Tests. You can use the childSelector() method to nest multiple UiSelector instances. For example, the following code example shows how your test might specify a search to find the first ListView in the currently displayed UI, then search within that ListView to find a UI element with the text property Apps. What is the correct sample?

  1. val appItem: UiObject = device.findObject(
    UiSelector().className(ListView.class)
    .instance(1)
    .childSelector(
    UiSelector().text("Apps")
    )
    )
  2. val appItem: UiObject = device.findObject(
    UiSelector().className("android.widget.ListView")
    .instance(0)
    .childSelector(
    UiSelector().text("Apps")
    )
    )
  3. val appItem: UiObject = device.findObject(
    UiSelector().className("android.widget.ListView")
    .instance(
    UiSelector().text("Apps")
    )
    )

Answer(s): B



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

  1. @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()))
    }
  2. @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()))
    }
  3. @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()))
    }

Answer(s): B



As an example. In an Activity we have our TimerViewModel object (extended ViewModel), named
mTimerViewModel. mTimerViewModel.timer method returns a LiveData<Long> value.

What can be a correct way to set an observer to change UI in case if data was changed?

  1. mTimerViewModel!!.timer.value.toString().observe
    (Observer { aLong -> callAnyChangeUIMethodHere(aLong!!) })
  2. mTimerViewModel!!.timer.observe
    (this, Observer { aLong -> callAnyChangeUIMethodHere(aLong!!) })
  3. mTimerViewModel.observe
    (Observer { aLong -> callAnyChangeUIMethodHere(aLong!!) })

Answer(s): B



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?

  1. The value "b" would be set at first and later the main thread would override it with the value "a".
  2. The value "a" would be set at first and later the main thread would override it with the value "b".
  3. The value "b" would be set at first and would not be overridden with the value "a".
  4. The value "a" would be set at first and would not be overridden with the value "b".

Answer(s): B



In our TeaViewModel class, that extends ViewModel, we have such prorerty:
val tea: LiveData<Tea>

An observer in our Activity (type of mViewModel variable in example is TeaViewModel) is set in this way:
mViewModel!!.tea.observe(this, Observer { tea: Tea? -> displayTea(tea) })

What will be a correct displayTea method definition?

  1. private fun displayTea()
  2. private fun displayTea(tea: Tea?)
  3. private fun displayTea(tea: LiveData?<Tea>)
  4. private fun displayTea(tea: LiveData?<T>)

Answer(s): B



Share your comments for Google ASSOCIATE ANDROID DEVELOPER exam with other users:

U
Umar Ali
8/29/2023 2:59:00 PM

A and D are True

V
vel
8/28/2023 9:17:09 AM

good one with explanation

G
Gurdeep
1/18/2024 4:00:15 PM

This is one of the most useful study guides I have ever used.

AI Tutor 👋 I’m here to help!