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

Viewing page 4 out of 4 pages
Viewing questions 31-40 out of questions
Questions # 31:

We have a custom view that extends android.widget.ProgressBar. Our progress bar is not touchable, focusable, etc.: it just shows progress. Style for our custom progress bar extends

“Widget.AppCompat.ProgressBar.Horizontal”. An item, named “progressDrawable”, in our style, is a xml file . What we usually can see as a main single element in this xml file:

Options:

A.

A State List ( element )


B.

A Layer List ( element) with items android:id="@+id/progress" and android:id="@+id/ background" inside it.


C.

An element with android:id="@+id/progress" identifier


Questions # 32:

Custom views and directional controller clicks. On most devices, clicking a view using a directional controller sends (to the view currently in focus) a KeyEvent with:

Options:

A.

KEYCODE_DPAD_CENTER


B.

KEYCODE_BUTTON_START


C.

KEYCODE_CALL


D.

KEYCODE_BUTTON_SELECT


Questions # 33:

For example, we have a BufferedReader reader, associated with the json file through

InputStreamReader. To get a file data we can do this:

Options:

A.

String line; try {

while ((line = reader.readLine()) != null) { builder.append(line);

}

JSONObject json = new JSONObject(builder.toString());

return json;

} catch (IOException | JSONException exception) {

exception.printStackTrace();

}


B.

JSONObject line; try {

while ((line = reader.readJSONObject ()) != null) { builder.append(line);

}

JSONObject json = new JSONObject(builder.toString());

return json;

} catch (IOException | JSONException exception) {

exception.printStackTrace();

}


C.

String line; try {

while ((line = reader.readLine()) != null) { builder.append(line);

}

JSONObject json = new JSONObject(builder.toString());

return json;

} catch (RuntimeException|ArrayIndexOutOfBoundsException exception) {

exception.printStackTrace();

}


Questions # 34:

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?

Options:

A.

mTimerViewModel.getTimer().getValue().toString().observe(new Observer() {

@Override

public void onChanged(Long aLong) {

callAnyChangeUIMethodHere(aLong)

}

});


B.

mTimerViewModel.getTimer().observe(this, new Observer() {

@Override

public void onChanged(Long aLong) {

callAnyChangeUIMethodHere(aLong)

}

});


C.

mTimerViewModel.observe(new Observer() {

@Override

public void onChanged(Long aLong) {

callAnyChangeUIMethodHere(aLong)

}

});


Questions # 35:

Select a correct statement about PagedList.

Options:

A.

PagedList is content-mutable. This means that new content can be loaded into an instance of PagedList and the loaded items themselves can change once loaded.


B.

PagedList is content-immutable. This means that, although new content can be loaded into an instance of PagedList, the loaded items themselves cannot change once loaded.


C.

PagedList is content-accidental. This means that new content can be loaded into an instance of PagedList and the loaded items themselves can be changed to accidental values randomly.


Questions # 36:

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

Options:

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

}


Questions # 37:

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

android:title="@string/pref_sort_title" android:summary="@string/pref_sort_summary" android:dialogTitle="@string/pref_sort_dialog_title" android:entries="@array/sort_oder" android:entryValues="@array/sort_oder_value" android:defaultValue="@string/pref_default_sort_value" app:iconSpaceReserved="false" />

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

Options:

A.

String sortBy = PreferenceManager.getDefaultSharedPreferences(getContext ()).getString(

getContext().getString(R.string.pref_sort_key), getContext().getResources().getBoolean(R.bool.pref_default_sort_value)

);


B.

String sortBy = PreferenceManager.getSharedPreferences(getContext()).getString( getContext().getString(R.string.pref_default_sort_value), getContext().getString(R.string.pref_sort_key)

);


C.

boolean sortBy = PreferenceManager.getSharedPreferences(getContext()).getBoolean (

getContext().getResources().getBoolean(R.bool.pref_default_sort_value), getContext().getString(R.string.pref_sort_key)

);


D.

String sortBy = PreferenceManager.getDefaultSharedPreferences(getContext ()).getString(

getContext().getString(R.string.pref_sort_key), getContext().getString(R.string.pref_default_sort_value)

)


Questions # 38:

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:

Options:

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

}


Viewing page 4 out of 4 pages
Viewing questions 31-40 out of questions