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

Google Associate-Android-Developer Google Developers Certification - Associate Android Developer (Kotlin and Java Exam) Exam Practice Test

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

Testing Engine

  • Product Type: Testing Engine
$42  $119.99

PDF Study Guide

  • Product Type: PDF Study Guide
$36.75  $104.99
Question 1

Working with Custom View. To define custom attributes, we can add resources to our project. It is customary to put these resources into a file:

Options:

A.

res/layout/attrs.xml

B.

res/values/attrs.xml

C.

res/raw/attrs.xml

D.

res/xml/attrs.xml

Question 2

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.

Question 3

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

}

Question 4

When scheduling unique work, you must tell WorkManager what action to take when there is a conflict. You do this by passing an enum when enquing the work. For one-time work, you provide an ExistingWorkPolicy, which supports some options for handling the conflict. (Choose four.)

Options:

A.

REPLACE (existing work with the new work. This option cancels the existing work)

B.

KEEP (existing work and ignore the new work)

C.

APPEND (the new work to the end of the existing work. This policy will cause your new work to be chained to the existing work, running after the existing work finishes)

D.

APPEND_OR_REPLACE (functions similarly to APPEND, except that it is not dependent on prerequisite work status. If the existing work is CANCELLED or FAILED, the new work still runs)

E.

APPEND_OR_KEEP (functions similarly to APPEND, except that it is not dependent on prerequisite work status. If the existing work is CANCELLED or FAILED, the new work still not runs)

F.

APPEND_AND_RUN (functions similarly to APPEND, except that it is not dependent on prerequisite work status. If the existing work is PAUSED, the new work still runs)

G.

DESTROY (if any work exists, the new work will be ignored)

Question 5

“Set the activity content to an explicit view. This view is placed directly into the activity's view hierarchy. It can itself be a complex view hierarchy.” This can be done by calling method:

Options:

A.

findViewById

B.

setContentView

C.

setActionBar

D.

setContentTransitionManager

E.

setTheme

Question 6

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.

InputStream input = context.openRawResource(R.raw.sample_teas);

B.

InputStream input = context.getRawResource(R.raw.sample_teas);

C.

InputStream input = context.getResources().openRawResource(R.raw.sample_teas);

Question 7

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

Question 8

In application theme style, flag windowActionBar () indicates:

Options:

A.

whether the given application component is available to other applications.

B.

whether action modes should overlay window content when there is not reserved space for their UI (such as an Action Bar).

C.

whether this window's Action Bar should overlay application content.

D.

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

Question 9

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)

Question 10

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

}

Question 11

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)

)

Question 12

When your code execution reaches the breakpoint, Android Studio pauses execution of your app. You can then use the tools in the Debugger tab to identify the state of the app. With Step Over you can

Options:

A.

examine the object tree for a variable; expand it in the Variables view.

B.

evaluate an expression at the current execution point

C.

advance to the next line in the code (without entering a method)

D.

advance to the first line inside a method call

E.

advance to the next line outside the current method

F.

continue running the app normally

Question 13

To create a basic JUnit 4 test class, create a class that contains one or more test methods. A test method begins with the specific annotation and contains the code to exercise and verify a single functionality in the component that you want to test. What is the annotation?

Options:

A.

@RunWith

B.

@LargeTest

C.

@Rule

D.

@Test

Question 14

When your code execution reaches the breakpoint, Android Studio pauses execution of your app. You can

then use the tools in the Debugger tab to identify the state of the app. With Step Out you can

Options:

A.

examine the object tree for a variable; expand it in the Variables view. If the Variables view is not visible

B.

evaluate an expression at the current execution point

C.

advance to the next line in the code (without entering a method)

D.

advance to the first line inside a method call

E.

advance to the next line outside the current method

F.

continue running the app normally

Question 15

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.

Question 16

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

}

Question 17

What statements about InputStreamReader (java.io.InputStreamReader) are correct? (Choose two.)

Options:

A.

An InputStreamReader is a bridge from byte streams to character streams: It reads bytes and decodes them into characters using a specified charset. The charset that it uses may be specified by name or may be given explicitly, or the platform's default charset may be accepted.

B.

An InputStreamReader is a bridge from character streams to byte streams: It reads characters using a specified charset and encodes them into bytes. The charset that it uses may be specified by name or may be given explicitly, or the platform's default charset may be accepted.

C.

Each invocation of one of an InputStreamReader's read() methods may cause one or more bytes to be read from the underlying byte-input stream. To enable the efficient conversion of bytes to characters, more bytes may be read ahead from the underlying stream than are necessary to satisfy the current read operation.

D.

No any invocation of one of an InputStreamReader's read() methods can cause some bytes to be read from the underlying byte-input stream.

Question 18

With a room database. When performing queries, you'll often want your app's UI to update automatically when the data changes. Can you use a return value of type LiveData in your query method description to achieve this?

Options:

A.

Yes

B.

No

Question 19

To run a debuggable build variant you must use a build variant that includes

Options:

A.

minifyEnabled false in the build configuration

B.

debuggable true or debuggable false in the build configuration

C.

debuggable true in the build configuration