nerdexam
Android

AND-401 · Question #104

AND-401 Question #104: Real Exam Question with Answer & Explanation

The correct answer is A. if (cursor.moveToFirst()) {. See the full explanation below for the reasoning.

Question

Consider the following code snippet: 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?

Options

  • Aif (cursor.moveToFirst()) {
  • Bdo {
  • Cif (cursor.moveToFirst()) {
  • Dif (cursor != null) {

Community Discussion

No community discussion yet for this question.

Full AND-401 Practice