Winter Sale Special 65% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: ex2p65

Exact2Pass Menu

Question # 4

In our TeaViewModel class, that extends ViewModel, we have such prorerty:

val tea: LiveData

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

mViewModel!!.tea.observe(this, Observer { tea: Tea? -> displayTea(tea) })

What will be a correct displayTea method definition?

A.

private fun displayTea()

B.

private fun displayTea(tea: Tea?)

C.

private fun displayTea(tea: LiveData?)

D.

private fun displayTea(tea: LiveData?)

Full Access
Question # 5

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 fun dispatchPopulateAccessibilityEvent(event: AccessibilityEvent): Boolean {

return super.dispatchPopulateAccessibilityEvent(event).let { completed -> if (text?.isNotEmpty() == true) {

event.text.add(text) true

} else {

completed

}

}

}

B.

override fun onKeyUp(keyCode: Int, event: KeyEvent): Boolean { return when(keyCode) {

KeyEvent.KEYCODE_DPAD_LEFT -> {

currentValue--

sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED)

true

}

...

}

}

C.

override fun onKeyUp(keyCode: Int, event: KeyEvent): Boolean { return when(keyCode) {

KeyEvent.KEYCODE_ENTER -> {

currentValue--

sendAccessibilityEvent

(AccessibilityEvent.TYPE_VIEW_CONTEXT_CLICKED)

true

}

...

}

}

Full Access
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:

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)

Full Access
Question # 7

The diagram below shows a basic form of the recommended architecture for apps that use Architecture Components. The architecture consists of a UI controller, a ViewModel that serves LiveData, a Repository, and a Room database. Drag modules to correct places.

Full Access
Question # 8

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".

Full Access
Question # 9

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?

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

Full Access
Question # 10

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

A.

@Rule

fun 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

fun 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

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

}

Full Access
Question # 11

RecyclerView is a subclass of ViewGroup and is a more resource-efficient way to display scrollable lists. Instead of creating a View for each item that may or may not be visible on the screen, RecyclerView:

A.

creates a single list item and reuses it for visible content.

B.

creates an unlimited number of list items and never reuses them

C.

creates a limited number of list items and reuses them for visible content.

D.

creates a single list item and never reuses it

Full Access
Question # 12

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?

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)

Full Access
Question # 13

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

}

Full Access
Question # 14

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?

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.

Full Access
Question # 15

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

A.

setContentInfo

B.

setContentIntent

C.

setDeleteIntent

Full Access
Question # 16

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?

A.

RecyclerView.AdapterDataObserver

B.

RecyclerView.ItemDecoration

C.

RecyclerView.ViewHolder

D.

RecyclerViewAccessibilityDelegate

Full Access
Question # 17

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

Example:

@Dao

public interface MyDao {

@Update

public void updateUsers(User... users);

}

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.

Full Access
Question # 18

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

Full Access
Question # 19

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

A.

onDismissed()

B.

onToastHidden()

C.

onShown()

D.

onToastShown()

E.

onToastCancelled()

Full Access