Sapient Company Programming

Answer the statements which are correct about Handler class

A. A handler object registers itself with the thread in which it is created.
B. The data which can be posted via the Handler class cannot be an instance of the Message or the Runnable class.
C. A Handler is particulary useful if you want to post data multiple times to the main thread

1) A and B
2) B and C
3) C and A
4) All of the given options

Read Solution (Total 1)

Sapient Other Question

The following syntax is used to implement loader class in Android getLoaderManager().initLoader(0,null,this);

Which of the following is correct about parameters taken by initLoader method?

1) first parameter: Unique Id
second parameter: A Bundle
third parameter: Callback class

2) first parameter: Unique Id
second parameter: CallBack class
third parameter: A bundle

3) first parameter: Callback class
second parameter: Unique id
third parameter: A bundle

4) None of the given options
Identify the correct inference from this piece of code:

public void onClick(View v){
new Runnable(){
public void run(){
Bitmap b = loadImageFromNetwork();
mImageView.setImageBitmap(b);

}
}).start():}

1) Here ImageView is manipulated on a worker thead which can cause really weird problems. Tracking down and fixing such bugs can be difficult and time consuming.

2) Here ImageView is manipulated on main thread. which is efficient & less time consuming.

3) Here ImageView is manipulated on main thread, which is asynchronous but time consuming.

4) Here ImageView is manipulated on a main thread, but this can cause weird problems. Tracking down and fixing such bugs can be difficult and time consuming.