Summer Special Sale - Limited Time 60% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: 575363r9

Welcome To DumpsPedia

Associate-Android-Developer Sample Questions Answers

Questions 4

Custom views and directional controller clicks. In general, you should send an AccessibilityEvent whenever the content of your custom view changes. For example, if a text value was changed in your custom view, you should emit an event of this type:

Options:

A.

TYPE_WINDOWS_CHANGED

B.

TYPE_VIEW_CONTEXT_CLICKED

C.

TYPE_WINDOWS_CHANGED

D.

TYPE_VIEW_TEXT_CHANGED

Buy Now
Questions 5

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

}

Buy Now
Questions 6

Assume that you have the following situation: The app code calls for R.string.text_a Three relevant resource files are available:

-res/values/strings.xml, which includes text_a in the app's default language, in this case English.

-res/values-mcc404/strings.xml, which includes text_a in the app's default language, in this case English.

-res/values-hi/strings.xml, which includes text_a in Hindi.

The app is running on a device that has the following configuration:

-The SIM card is connected to a mobile network in India (MCC 404).

-The language is set to Hindi (hi).

Which is the correct statement below?

Options:

A.

Android loads text_a from res/values/strings.xml (in English)

B.

Android loads text_a from res/values-mcc404/strings.xml (in English)

C.

Android loads text_a from res/values-hi/strings.xml (in Hindi)

Buy Now
Questions 7

Assume that an app includes a default set of graphics and two other sets of graphics, each optimized for a different device setup:

res/drawable/

Contains default graphics. res/drawable-small-land-stylus/

Contains graphics optimized for use with a device that expects input from a stylus and has a QVGA low- density screen in landscape orientation.

res/drawable-ja/

Contains graphics optimized for use with Japanese.

What happens if the app runs on a device that is configured to use Japanese and, at the same time, the device happens to be one that expects input from a stylus and has a QVGA low-density screen in landscape orientation?

Options:

A.

Android loads graphics from res/drawable/

B.

Android loads graphics from res/drawable-small-land-stylus/

C.

Android loads graphics from res/drawable-ja/

Buy Now
Questions 8

When using an EditTexts or editable TextViews, or other editable View. What attribute to use to provide a content label for that View?

Options:

A.

android:contentDescription

B.

android:hint

C.

android:labelFor

Buy Now
Questions 9

In application theme style, flag windowNoTitle () indicates:

Options:

A.

whether this window should have an Action Bar in place of the usual title bar.

B.

whether there should be no title on this window.

C.

that this window should not be displayed at all.

D.

whether this is a floating window.

E.

whether this Window is responsible for drawing the background for the system bars.

Buy Now
Questions 10

A content label sometimes depends on information only available at runtime, or the meaning of a View might change over time. For example, a Play button might change to a Pause button during music playback. In these cases, to update the content label at the appropriate time, we can use:

Options:

A.

View#setContentDescription(int contentDescriptionResId)

B.

View#setContentLabel(int contentDescriptionResId)

C.

View#setContentDescription(CharSequence contentDescription)

D.

View#setContentLabel(CharSequence contentDescription)

Buy Now
Questions 11

What happens when you create a DAO method and annotate it with @Insert?

Example:

@Dao

public interface MyDao {

@Insert(onConflict = OnConflictStrategy.REPLACE)

public void insertUsers(User... users);

}

Options:

A.

Room generates an implementation that inserts all parameters into the database in a single transaction.

B.

Room modifies a set of entities, given as parameters, in the database. It uses a query that matches against the primary key of each entity.

C.

Room removes a set of entities, given as parameters, from the database. It uses the primary keys to find the entities to delete.

Buy Now
Questions 12

Custom duration in milliseconds as a parameter for the setDuration method is available when you are working with:

Options:

A.

Toast

B.

Snackbar

C.

for none of them

D.

for both of them

Buy Now
Questions 13

What method should we use with Notification.Builder to supply a PendingIntent to be sent when the notification is clicked?

Options:

A.

setContentInfo

B.

setContentIntent

C.

setDeleteIntent

Buy Now
Questions 14

Relative positioning is one of the basic building blocks of creating layouts in ConstraintLayout. Constraints allow you to position a given widget relative to another one. What constraints do not exist?

Options:

A.

layout_constraintBottom_toBottomOf

B.

layout_constraintBaseline_toBaselineOf

C.

layout_constraintBaseline_toStartOf

D.

layout_constraintStart_toEndOf

Buy Now
Questions 15

If constant LENGTH_INDEFINITE is used as a parameter for the setDuration method in Snackbar, what will happen?

Options:

A.

The Snackbar will be displayed for a short period of time.

B.

The Snackbar will be displayed for a long period of time.

C.

The Snackbar will be displayed for a very long period of time.

D.

The Snackbar will be displayed from the time that is shown until either it is dismissed, or another Snackbar is shown.

E.

The constant LENGTH_INDEFINITE is impossible parameter for the setDuration method in Snackbar

Buy Now
Questions 16

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

android:title="@string/pref_notification_title" android:summary="@string/pref_notification_summary" android:defaultValue="@bool/pref_notification_default_value" app:iconSpaceReserved="false"/>

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

Options:

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)

);

Buy Now
Questions 17

What public methods are there in android.widget.Toast.Callback? (Choose two.)

Options:

A.

onDismissed()

B.

onToastHidden()

C.

onShown()

D.

onToastShown()

E.

onToastCancelled()

Buy Now
Questions 18

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.

var line: String? try {

while (reader.readLine().also { line = it } != null) { builder.append(line)

}

val json = JSONObject(builder.toString())

return json

} catch (exception: IOException) {

exception.printStackTrace()

} catch (exception: JSONException) {

exception.printStackTrace()

}

B.

var line: JSONObject ? try {

while (reader.readJSONObject ().also { line = it } != null) {

builder.append(line)

}

val json = JSONObject(builder.toString())

return json

} catch (exception: IOException) {

exception.printStackTrace()

} catch (exception: JSONException) {

exception.printStackTrace()

}

C.

var line: String? try {

while (reader.readLine().also { line = it } != null) { builder.append(line)

}

val json = JSONObject(builder.toString())

return json

} catch (exception: RuntimeException) {

exception.printStackTrace()

} catch (exception: ArrayIndexOutOfBoundsException) {

exception.printStackTrace()

}

Buy Now
Questions 19

Room can export your database's schema information into a JSON file at compile time. What annotation processor property you should set in your app/build.gradle file to export the schema?

Options:

A.

room.expandProjection

B.

room.incremental

C.

room.schemaLocation

Buy Now
Questions 20

The Layout Inspector in Android Studio allows you to compare your app layout with design mockups, display a magnified or 3D view of your app, and examine details of its layout at runtime. When this is especially useful?

Options:

A.

when your layout is built entirely in XML rather than runtime and the layout is behaving expectedly.

B.

when your layout is built at runtime rather than entirely in XML and the layout is behaving unexpectedly.

Buy Now
Questions 21

In a class PreferenceFragmentCompat. What method is called during onCreate(Bundle) to supply the preferences for this fragment. And where subclasses are expected to call setPreferenceScreen (PreferenceScreen) either directly or via helper methods such as addPreferencesFromResource (int)?

Options:

A.

onCreateLayoutManager

B.

onCreatePreferences

C.

onCreateRecyclerView

D.

onCreateView

Buy Now
Questions 22

What do you want from Room when you create a DAO method and annotate it with @Update?

Example:

@Dao

interface MyDao {

@Update

fun updateUsers(vararg users: User)

}

Options:

A.

Room generates an implementation that inserts all parameters into the database in a single transaction.

B.

Room modifies a set of entities, given as parameters, in the database. It uses a query that matches against the primary key of each entity.

C.

Room removes a set of entities, given as parameters, from the database. It uses the primary keys to find the entities to delete.

Buy Now
Questions 23

An overridden method onCreateOptionsMenu in an Activity returns boolean value. What does this value mean?

Options:

A.

You must return true for the menu to be displayed; if you return false it will not be shown.

B.

You must return false for the menu to be displayed; if you return true it will not be shown.

C.

You can return any value: the menu will be displayed anyway.

Buy Now
Questions 24

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

Buy Now
Questions 25

What do you want from Room when you create a DAO method and annotate it with @Delete?

Example:

@Dao

public interface MyDao {

@Delete

public void deleteUsers(User... users);

}

Options:

A.

Room generates an implementation that inserts all parameters into the database in a single transaction.

B.

Room modifies a set of entities, given as parameters, in the database. It uses a query that matches against the primary key of each entity.

C.

Room removes a set of entities, given as parameters, from the database. It uses the primary keys to find the entities to delete.

Buy Now
Questions 26

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:

Options:

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)

Buy Now
Questions 27

SharedPreferences.Editor is an interface used for modifying values in a SharedPreferences object. All changes you make in an editor are batched, and not copied back to the original SharedPreferences until you call:

Options:

A.

commit()

B.

apply()

C.

commit() or apply()

Buy Now
Questions 28

@Query is the main annotation used in DAO classes. It allows you to perform read/write operations on a database. Each @Query method is verified at compile time, so what happens if there is a problem with the query?

Options:

A.

a runtime error occurs instead of a compilation failure.

B.

a compilation error occurs instead of a runtime failure.

C.

both compilation error and runtime failure occurs.

Buy Now
Questions 29

The Log class allows you to create log messages that appear in logcat. Generally, you could use the following log methods: (Choose five.)

Options:

A.

Log.e(String, String) (error)

B.

Log.a(String, String) (all outputs)

C.

Log.w(String, String) (warning)

D.

Log.i(String, String) (information)

E.

Log.q(String, String) (QUESTION NO:s)

F.

Log.d(String, String) (debug)

G.

Log.v(String, String) (verbose)

Buy Now
Questions 30

An example. In our ViewModelFactory (that implements ViewModelProvider.Factory) we have an instance of our Repository, named mRepository. Our ViewModel has such constructor:

class MyViewModel(private val mRepository: MyRepository) : ViewModel() ...

Next, in our ViewModelFactory create ViewModel method (overriden) looks like this:

override fun create(modelClass: Class): T {

return try {

//MISSED RETURN VALUE HERE”

} catch (e: InstantiationException) {

throw RuntimeException("Cannot create an instance of $modelClass", e)

} catch (e: IllegalAccessException) {

throw RuntimeException("Cannot create an instance of $modelClass", e)

} catch (e: NoSuchMethodException) {

throw RuntimeException("Cannot create an instance of $modelClass", e)

} catch (e: InvocationTargetException) {

throw RuntimeException("Cannot create an instance of $modelClass", e)

}

}

What should we write instead of “//MISSED RETURN VALUE HERE”?

Options:

A.

modelClass.getConstructor()

.newInstance(mRepository)

B.

modelClass.getConstructor(MyRepository::class.java)

.newInstance()

C.

modelClass.getConstructor(MyRepository::class.java)

.newInstance(mRepository)

Buy Now
Questions 31

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

Options:

A.

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

B.

val input = context!!.assets.open("sample_teas.json")

C.

val input = context!!.resources.assets.open("sample_teas.json")

Buy Now
Questions 32

Interface for a callback to be invoked when a shared preference is changed. Interface is named:

Options:

A.

android.content.SyncStatusObserver

B.

android.content.SharedPreferences.Editor

C.

android.content.SharedPreferences.OnSharedPreferenceChangeListener

D.

android.content.SharedPreferences

Buy Now
Questions 33

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?

Options:

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!!) })

Buy Now
Questions 34

Filter logcat messages. If in the filter menu, a filter option “Show only selected application”? means:

Options:

A.

Display the messages produced by the app code only (the default). Logcat filters the log messages using the PID of the active app.

B.

Apply no filters. Logcat displays all log messages from the device, regardless of which process you selected.

C.

Create or modify a custom filter. For example, you could create a filter to view log messages from two apps at the same time.

Buy Now
Questions 35

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

android:title="@string/pref_notification_title" android:summary="@string/pref_notification_summary" android:defaultValue="@bool/pref_notification_default_value" app:iconSpaceReserved="false"/>

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

Options:

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)

)

Buy Now
Questions 36

In a class extended PreferenceFragmentCompat. What method is used to inflate the given XML resource and add the preference hierarchy to the current preference hierarchy?

Options:

A.

findPreference

B.

getPreferenceManager

C.

addPreferencesFromResource

D.

setPreferenceScreen

Buy Now
Questions 37

Content labels. What attribute to use to indicate that a View should act as a content label for another View?

Options:

A.

android:contentDescription

B.

android:hint

C.

android:labelFor

Buy Now
Questions 38

Android uses adapters (from the Adapter class) to connect data with View items in a list. There are many different kinds of adapters available, and you can also write custom adapters. To connect data with View items, the adapter needs to know about the View items. From what is extended the entity that is usually used in an adapter and describes a View item and its position within the RecyclerView?

Options:

A.

RecyclerView.AdapterDataObserver

B.

RecyclerView.ItemDecoration

C.

RecyclerView.ViewHolder

D.

RecyclerViewAccessibilityDelegate

Buy Now
Exam Code: Associate-Android-Developer
Exam Name: Google Developers Certification - Associate Android Developer (Kotlin and Java Exam)
Last Update: Apr 16, 2025
Questions: 128
$66  $164.99
$50  $124.99
$42  $104.99
buy now Associate-Android-Developer