Labour Day Special - Limited Time 65% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: top65certs

Google Associate-Android-Developer Dumps

Google Developers Certification - Associate Android Developer (Kotlin and Java Exam) Questions and Answers

Question 1

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.

Question 2

Under the hood WorkManager uses an underlying job dispatching service based on the following criteria. You need to move services to the correct places.

Options:

Question 3

In Android 8.0, API level 26, some APIs regarding notification behaviors were moved from Notification to NotificationChannel. For example, what should we use instead of NotificationCompat.Builder.setPriority() for Android 8.0 and higher?

Options:

A.

NotificationChannel.setPriority()

B.

NotificationChannel.setImportance()

C.

NotificationCompat.Builder.setImportance()

Question 4

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

Question 5

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)

}

});

Question 6

If no any folder like res/anim-, res/drawable-, res/layout-, res/raw-

, res/xml- exist in the project. Which folders are required in the project anyway? (Choose two.)

Options:

A.

res/anim/

B.

res/drawable/

C.

res/layout/

D.

res/raw/

E.

res/xml/

Question 7

For example, suppose that in a XML file (res/menu/menu_main.xml as an example), where menu items are described, we have such item:

...

android:id="@+id/action_settings"

android:orderInCategory="100"

android:title="@string/menu_action_settings"

app:showAsAction="never" />

...

Attribute “app:showAsAction” shows when and how this item should appear as an action item in the app bar. What value “never” in this attribute means?

Options:

A.

Only place this item in the app bar if there is room for it. If there is not room for all the items marked by this value, the items with the lowest orderInCategory values are displayed as actions, and the remaining items are displayed in the overflow menu.

B.

Also include the title text (defined by android:title) with the action item. You can include this value along with one of the others as a flag set, by separating them with a pipe.

C.

Never place this item in the app bar. Instead, list the item in the app bar's overflow menu.

D.

Always place this item in the app bar. Avoid using this unless it's critical that the item always appear in the action bar. Setting multiple items to always appear as action items can result in them overlapping with other UI in the app bar.

E.

The action view associated with this action item (as declared by android:actionLayout or android:actionViewClass) is collapsible.

Question 8

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)

)

Question 9

What is demonstrated by the code below?

// RawDao.java

@Dao

interface RawDao {

@RawQuery

User getUserViaQuery(SupportSQLiteQuery query);

}

// Usage of RawDao

...

SimpleSQLiteQuery query =

new SimpleSQLiteQuery("SELECT * FROM UserWHERE id = ? LIMIT 1",

new Object[]{userId});

User user = rawDao.getUserViaQuery(query);

...

Options:

A.

A method in a Dao annotated class as a raw query method where you can pass the query as a

SupportSQLiteQuery.

B.

A method in a Dao annotated class as a query method.

C.

A method in a RoomDatabase class as a query method.

Question 10

If you want get a debuggable APK that people can install without adb, in Android Studio you can:

Options:

A.

Select your debug variant and click Build Bundle(s) / APK(s) > Build APK(s).

B.

Click the Run button from toolbar

C.

Select your debug variant and click Analyze APK.

Question 11

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

Question 12

What is a correct part of an Implicit Intent for sharing data implementation?

Options:

A.

val sendIntent = Intent(this, UploadService::class.java).apply { putExtra(Intent.EXTRA_TEXT, textMessage)

...

B.

val sendIntent = Intent().apply { type = Intent.ACTION_SEND;

...

C.

val sendIntent = Intent(this, UploadService::class.java).apply { data = Uri.parse(fileUrl)

...

D.

val sendIntent = Intent().apply { action = Intent.ACTION_SEND

...

Question 13

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)

Question 14

By adding a RoomDatabase.Callback to the room database builder RoomDatabase.Builder (method

addCallback(RoomDatabase.Callback callback)), we can: (Choose two.)

Options:

A.

set the database factory

B.

handle database first time creation

C.

handle database opening

D.

disable the main thread query check for Room

Question 15

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

Question 16

Filter logcat messages. If in the filter menu, a filter option “Edit Filter Configuration”? 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.

Question 17

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.

Question 18

SharedPreferences.Editor is an interface used for modifying values in a SharedPreferences object. To mark in the editor that a preference value should be removed, which will be done in the actual preferences once commit() or apply() is called, what method in SharedPreferences.Editor should we use?

Options:

A.

delete(String key)

B.

clear()

C.

remove(String key)

D.

removeAll()

Question 19

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

Example:

@Dao

interface MyDao {

@Insert(onConflict = OnConflictStrategy.REPLACE)

fun insertUsers(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.