Google Associate Android Developer Exam Practice Questions (P. 2)
- Full Access (107 questions)
- Six months of Premium Access
- Access to one million comments
- Seamless ChatGPT Integration
- Ability to download PDF files
- Anki Flashcard files for revision
- No Captcha & No AdSense
- Advanced Exam Configuration
Question #6
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?
- Aval appItem: UiObject = device.findObject( UiSelector().className(ListView.class) .instance(1) .childSelector( UiSelector().text("Apps") ) )
- Bval appItem: UiObject = device.findObject( UiSelector().className("android.widget.ListView") .instance(0) .childSelector( UiSelector().text("Apps") ) )
- Cval appItem: UiObject = device.findObject( UiSelector().className("android.widget.ListView") .instance( UiSelector().text("Apps") ) )
Correct Answer:
B
B
send
light_mode
delete
Question #7
The following code snippet shows an example of an Espresso test:
- 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())) }
Correct Answer:
B
B
send
light_mode
delete
Question #8
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?
- AmTimerViewModel!!.timer.value.toString().observe (Observer { aLong -> callAnyChangeUIMethodHere(aLong!!) })
- BmTimerViewModel!!.timer.observe (this, Observer { aLong -> callAnyChangeUIMethodHere(aLong!!) })
- CmTimerViewModel.observe (Observer { aLong -> callAnyChangeUIMethodHere(aLong!!) })
Correct Answer:
B
B
send
light_mode
delete
Question #9
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?
What will be the correct statement?
- AThe value "b" would be set at first and later the main thread would override it with the value "a".
- BThe value "a" would be set at first and later the main thread would override it with the value "b".
- CThe value "b" would be set at first and would not be overridden with the value "a".
- DThe value "a" would be set at first and would not be overridden with the value "b".
Correct Answer:
B
B
send
light_mode
delete
Question #10
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?
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?
- Aprivate fun displayTea()
- Bprivate fun displayTea(tea: Tea?)
- Cprivate fun displayTea(tea: LiveData?<Tea>)
- Dprivate fun displayTea(tea: LiveData?<T>)
Correct Answer:
B
B
send
light_mode
delete
All Pages