Sapient Company Programming Basics

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.

Read Solution (Total 1)

Sapient Other Question

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