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
    :

Google Google Certifications ASSOCIATE-ANDROID-DEVELOPER Questions & Answers

  • Question 51:

    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. boolean isNotificationOn = PreferenceManager.getDefaultSharedPreferences(getContext()).getBoolean(getContext().getString(R.string.pref_notification_key),getContext().getResources().getBoolean(R.bool.pref_notification_default_value)

    );

    B. boolean isNotificationOn = PreferenceManager.getSharedPreferences(getContext()).getBoolean(getContext().getString(R.string.pref_notification_default_value),getContext().getString(R.string.pref_notification_key)

    );

    C. boolean isNotificationOn = PreferenceManager.getSharedPreferences(getContext()).getBoolean(getContext().getResources().getBoolean(R.bool.pref_notification_default_value),getContext().getString(R.string.pref_notification_key)

    );

  • Question 52:

    In our TeaViewModelclass, that extends ViewModel, we have such method:

    public LiveData getTea() {return mTea;}

    An observer in our Activity (type of mViewModelvariable in example is TeaViewModel) is set in this way:

    mViewModel.getTea().observe(this, this::displayTea);

    What will be a correct displayTea method definition?

    A. private void displayTea()

    B. private void displayTea(Tea tea)

    C. private void displayTea(LiveData)

    D. private void displayTea(LiveData)

  • Question 53:

    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 54:

    As an example. In an Activity we have our TimerViewModel object (extended ViewModel), named mTimerViewModel. mTimerViewModel.getTimer() 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.getTimer().getValue().toString().observe(new Observer() {@Overridepublic void onChanged(Long aLong) {

    callAnyChangeUIMethodHere(aLong)

    }

    });

    B. mTimerViewModel.getTimer().observe(this, new Observer() {@Overridepublic void onChanged(Long aLong) {

    callAnyChangeUIMethodHere(aLong)

    }

    });

    C. mTimerViewModel.observe(new Observer() {@Overridepublic void onChanged(Long aLong) {

    callAnyChangeUIMethodHere(aLong)

    }

    });

  • Question 55:

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

    A. @Rule

    public void 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

    public void 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

    public void 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 56:

    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. UiObject appItem = device.findObject(new UiSelector().className(ListView.class).instance(1).childSelector(new UiSelector().text("Apps")));

    B. UiObject appItem = device.findObject(new UiSelector().className("android.widget.ListView").instance(0).childSelector(new UiSelector().text("Apps")));

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

  • Question 57:

    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

    public boolean onCreateOptionsMenu(Menu menu) {

    getMenuInflater().inflate(R.menu.menu_main, menu);

    return true;

    }

    B. @Override

    public boolean onOptionsItemSelected(MenuItem item) {

    getMenuInflater().inflate(R.menu.menu_main, menu);

    return super.onOptionsItemSelected(item);

    }

    C. @Override

    protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    setContentView(R.menu.menu_main);

    }

  • Question 58:

    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

    public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {

    boolean completed = super.dispatchPopulateAccessibilityEvent(event);

    CharSequence text = getText();

    if (!TextUtils.isEmpty(text)) {

    event.getText().add(text);

    return true;

    }

    return completed;

    }

    B. @Overridepublic boolean onKeyUp (int keyCode, KeyEvent event) {

    if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT) {

    currentValue--;

    sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED);

    return true;

    }

    ...

    }

    C. @Overridepublic boolean onKeyUp (int keyCode, KeyEvent event) {

    if (keyCode == KeyEvent.KEYCODE_ENTER) {

    currentValue--;

    sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CONTEXT_CLICKED);

    return true;

    }

    ...

    }

  • Question 59:

    "workManager" is an instance of WorkManager. Select correct demonstration of WorkRequest cancellation:

    A. workManager.enqueue(new OneTimeWorkRequest.Builder(FooWorker.class).build());

    B. WorkRequest request = new OneTimeWorkRequest.Builder(FooWorker.class).build();workManager.enqueue(request);LiveData status = workManager.getWorkInfoByIdLiveData(request.getId());status.observe(...);

    C. WorkRequest request = new OneTimeWorkRequest.Builder(FooWorker.class).build();workManager.enqueue(request);workManager.cancelWorkById(request.getId());

    D. WorkRequest request1 = new OneTimeWorkRequest.Builder(FooWorker.class).build();WorkRequest request2 = new OneTimeWorkRequest.Builder(BarWorker.class).build();WorkRequest request3 = new OneTimeWorkRequest.Builder(BazWorker.class).build();workManager.beginWith(request1, request2).then(request3).enqueue();

    E. WorkRequest request = new OneTimeWorkRequest.Builder(FooWorker.class).build();workManager.enqueue(request);workManager.cancelWork(request);

  • Question 60:

    By default, the notification's text content is truncated to fit one line. If you want your notification to be longer, for example, to create a larger text area, you can do it in this way:

    A. NotificationCompat.Builder builder = new NotificationCompat.Builder(this, CHANNEL_ID).setContentText("Much longer text that cannot fit one line...").setStyle(new NotificationCompat.BigTextStyle()

    .bigText("Much longer text that cannot fit one line..."))

    ...

    B. NotificationCompat.Builder builder = new NotificationCompat.Builder(this, CHANNEL_ID).setContentText("Much longer text that cannot fit one line...")

    .setLongText("Much longer text that cannot fit one line..."))

    ...

    C. NotificationCompat.Builder builder = new NotificationCompat.Builder(this, CHANNEL_ID).setContentText("Much longer text that cannot fit one line...")

    .setTheme(android.R.style.Theme_LongText);

    ...

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.