Free AND-401 Exam Braindumps (page: 26)

Page 25 of 58

Which of the following is NOT true about class AsyncTask?

  1. It must be used by sub-classing it.
  2. It must be created on the UI thread.
  3. Its sub-class override at least two methods: doInBackground, onPostExecute.
  4. It uses three generic types.

Answer(s): C

Explanation:

AsyncTask must be subclassed to be used. The subclass will override at least one method (doInBackground (Params...)), and most often will override a second one (onPostExecute(Result).)
Incorrect:
A: AsyncTask must be subclassed to be used.
B: AsyncTask enables proper and easy use of the UI thread. This class allows to perform background operations and publish results on the UI thread without having to manipulate threads and/or handlers. D: The three types used by an asynchronous task are the following:
Params, the type of the parameters sent to the task upon execution.
Progress, the type of the progress units published during the background computation. Result, the type of the result of the background computation.


Reference:

http://developer.android.com/reference/android/os/AsyncTask.html



What does the following line of code do?
Toast toast = Toast.makeText(this,"Android ATC", Toast.LENGTH_LONG); toast.setGravity(Gravity.TOP|Gravity.RIGHT, 0, 0);
toast.show( );

  1. The toast will have it UI components place on the top-right corner.
  2. The toast will appear on the top-right corner.
  3. The toast will show the text message on top-right corner of the toast box.
  4. The toast will appear at the center of the screen at position (0,0), but aligned to the top-right corner.

Answer(s): B


Reference:

http://tutorials.jenkov.com/android/toast.html



Which of the following is NOT true about a content provider?

  1. It manages access to structured data.
  2. It cannot be used from inside an Activity.
  3. It facilitates access to Android’s SQLite databases.
  4. To access data in it, method getContentResolver() of the application’s Context is used.

Answer(s): B

Explanation:

You can access data in a content provider, even if you don't have the proper access permissions, by sending an intent to an application that does have the permissions and receiving back a result intent containing "URI" permissions. These are permissions for a specific content URI that last until the activity that receives them is finished.
Incorrect:
A: A content provider manages access to a central repository of data.


Reference:

http://developer.android.com/guide/topics/providers/content-provider-basics.html



Consider the following code snippet to query SQLite database:

String[] result_columns = new String[] {KEY_ID, COL1, COL2};
Cursor allRows = myDatabase.query(true, DATABASE_TABLE, result_columns,
null, null, null, null, null, null);

Which of the following prints out the values of COL1 column correctly if the result is not empty?

  1. if (allRows.moveToFirst()) {
    do {
    System.out.println(allRows.getString(1));
    }
    while (allRows.moveToNext()); }
  2. do {
    System.out.println(allRows.getString(0));
    }
    while (allRows.moveToNext());
  3. if (allRows.moveToFirst()) { do {
    System.out.println(allRows.getString(0));
    }
    while (allRows.moveToNext()); }
  4. if (allRows!= null) { do {
    System.out.println(allRows.getString(1));
    }
    while (!allRows.isNull()); }

Answer(s): A






Post your Comments and Discuss Android AND-401 exam with other Community members: