PrepAway - Latest Free Exam Questions & Answers

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

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?

PrepAway - Latest Free Exam Questions & Answers

A.
if (cursor.moveToFirst()) {
do {
System.out.println(cursor.getString(1));
} while (cursor.moveToNext());
}

B.
do {
System.out.println(cursor.getString(0));
} while (cursor.moveToNext());

C.
if (cursor.moveToFirst()) {
do {
System.out.println(cursor.getString(0));
} while (cursor.moveToNext()); }

D.
if (cursor != null) {
do {
System.out.println(cursor.getString(1));
} while (!cursor.isNull());
}

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


Leave a Reply

Your email address will not be published. Required fields are marked *