Exam Details

  • Exam Code
    :ASSOCIATE-ANDROID-DEVELOPER
  • Exam Name
    :Google Developers Certification - Associate Android Developer (Kotlin and Java Exam)
  • Certification
    :Google Certifications
  • Vendor
    :Google
  • Total Questions
    :128 Q&As
  • Last Updated
    :May 03, 2024

Google Google Certifications ASSOCIATE-ANDROID-DEVELOPER Questions & Answers

  • Question 111:

    For example, we have a file in our raw folder app/src/main/res/raw/sample_teas.json. To get an InputStream for reading it, from out Context context, we can do this:

    A. val input = context!!.openRawResource(R.raw.sample_teas)

    B. val input = context!!.getRawResource(R.raw.sample_teas)

    C. val input = context!!.resources.openRawResource(R.raw.sample_teas)

  • Question 112:

    For example, our preferences.xmlfile was added by addPreferencesFromResource(R.xml.preferences). Our preferences.xmlfile contains such item:

    In our Fragment, we can dynamically get current notification preference value in this way:

    A. val sortBy = PreferenceManager.getDefaultSharedPreferences(context).getString(context!!.getString(R.string.pref_sort_key),context!!.resources.getBoolean(R.bool.pref_default_sort_value)

    )

    B. val sortBy = PreferenceManager.getSharedPreferences(context).getString(context!!.getString(R.string.pref_default_sort_value),context!!.getString(R.string.pref_sort_key),

    )

    C. val sortBy = PreferenceManager.getSharedPreferences(context).getBoolean(context!!.resources.getBoolean(R.bool.pref_default_sort_value),context!!.getString(R.string.pref_sort_key)

    )

    D. val sortBy = PreferenceManager.getDefaultSharedPreferences(context).getString(context!!.getString(R.string.pref_sort_key),context!!.getString(R.string.pref_default_sort_value)

    )

  • Question 113:

    For example, our preferences.xmlfile was added by addPreferencesFromResource(R.xml.preferences). Our preferences.xmlfile contains such item:

    In our Fragment, we can dynamically get current notification preference value in this way:

    A. val isNotificationOn = PreferenceManager.getDefaultSharedPreferences(context).getBoolean(context!!.getString(R.string.pref_notification_key),context!!.resources.getBoolean(R.bool.pref_notification_default_value)

    )

    B. val isNotificationOn = PreferenceManager.getSharedPreferences(context).getBoolean(context!!.getString(R.string.pref_notification_default_value),context!!.getString(R.string.pref_notification_key),

    )

    C. val isNotificationOn = PreferenceManager.getSharedPreferences(context).getBoolean(context!!.resources.getBoolean(R.bool.pref_notification_default_value),context!!.getString(R.string.pref_notification_key)

    )

  • Question 114:

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

    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?

    A. private fun displayTea()

    B. private fun displayTea(tea: Tea?)

    C. private fun displayTea(tea: LiveData?)

    D. private fun displayTea(tea: LiveData?)

  • Question 115:

    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?

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

  • Question 116:

    As an example. In an Activity we have our TimerViewModel object (extended ViewModel), named mTimerViewModel. mTimerViewModel.timer method returns a LiveData value. What can be a correct way to set an observer to change UI in case if data was changed?

    A. mTimerViewModel!!.timer.value.toString().observe (Observer { aLong -> callAnyChangeUIMethodHere(aLong!!) })

    B. mTimerViewModel!!.timer.observe (this, Observer { aLong -> callAnyChangeUIMethodHere(aLong!!) })

    C. mTimerViewModel.observe (Observer { aLong -> callAnyChangeUIMethodHere(aLong!!) })

  • Question 117:

    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()))

    }

  • Question 118:

    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?

    A. val appItem: UiObject = device.findObject(

    UiSelector().className(ListView.class)

    .instance(1)

    .childSelector(

    UiSelector().text("Apps")

    )

    )

    B. val appItem: UiObject = device.findObject(

    UiSelector().className("android.widget.ListView")

    .instance(0)

    .childSelector(

    UiSelector().text("Apps")

    )

    )

    C. val appItem: UiObject = device.findObject(UiSelector().className("android.widget.ListView").instance(UiSelector().text("Apps")

    )

    )

  • Question 119:

    The easiest way of adding menu items (to specify the options menu for an activity) is inflating an XML file into the Menu via MenuInflater. With menu_main.xml we can do it in this way:

    A. override fun onCreateOptionsMenu(menu: Menu): Boolean {menuInflater.inflate(R.menu.menu_main, menu)

    return true

    }

    return true

    }

    B. override fun onOptionsItemSelected(item: MenuItem): Boolean {menuInflater.inflate(R.menu.menu_main, menu)

    return super.onOptionsItemSelected(item)

    }

    C. override fun onCreate(savedInstanceState: Bundle?) {super.onCreate(savedInstanceState)setContentView(R.menu.menu_main)

    }

  • Question 120:

    In general, you should send an AccessibilityEvent whenever the content of your custom view changes. For example, if you are implementing a custom slider bar that allows a user to select a numeric value by pressing the left or right arrows, your custom view should emit an event of type TYPE_VIEW_TEXT_CHANGED whenever the slider value changes. Which one of the following sample codes demonstrates the use of the sendAccessibilityEvent() method to report this event.

    A. override fun dispatchPopulateAccessibilityEvent(event: AccessibilityEvent): Boolean {return super.dispatchPopulateAccessibilityEvent(event).let { completed ->

    if (text?.isNotEmpty() == true) {

    event.text.add(text)

    true

    } else {

    completed

    }

    }

    }

    B. override fun onKeyUp(keyCode: Int, event: KeyEvent): Boolean {return when(keyCode) {

    KeyEvent.KEYCODE_DPAD_LEFT -> {

    currentValue-sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED)

    true

    }

    ...

    }

    }

    C. override fun onKeyUp(keyCode: Int, event: KeyEvent): Boolean {return when(keyCode) {

    KeyEvent.KEYCODE_ENTER -> {

    currentValue-sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CONTEXT_CLICKED)

    true

    }

    ...

    }

    }

Tips on How to Prepare for the Exams

Nowadays, the certification exams become more and more important and required by more and more enterprises when applying for a job. But how to prepare for the exam effectively? How to prepare for the exam in a short time with less efforts? How to get a ideal result and how to find the most reliable resources? Here on Vcedump.com, you will find all the answers. Vcedump.com provide not only Google exam questions, answers and explanations but also complete assistance on your exam preparation and certification application. If you are confused on your ASSOCIATE-ANDROID-DEVELOPER exam preparations and Google certification application, do not hesitate to visit our Vcedump.com to find your solutions here.