wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Android Database and Layout Quiz

Total questions: 20

Worksheet time: 10mins

Name
Class
Date
1.

What is the primary function of a GridLayout in Android?

a)

To display data from a SQLite database

b)

To create layouts with rounded corners and shadows

c)

To place its children in a rectangular grid of rows and columns

d)

To execute SQL queries

2.

Which of the following is a key feature of CardView?

a)

It automatically creates SQLite tables

b)

It executes the execSQL method

c)

It provides rounded corners and elevation (shadow)

d)

It defines the number of rows and columns for a database

3.

Which package contains the classes to manage your own SQLite databases in Android?

a)

android.view

b)

android.content

c)

android.database.sqlite

d)

android.widget

4.

Which SQL command is used to change a value in one or more existing rows of a table?

a)

INSERT

b)

SELECT

c)

DELETE

d)

UPDATE

5.

What is the purpose of the openOrCreateDatabase method in Android?

a)

It only opens an existing database in read-only mode

b)

It opens an existing database and creates it if it does not exist

c)

It is used to insert new rows into a table

d)

It closes the database connection

6.

Which method is commonly used to execute a SQL statement that creates a table or inserts data?

a)

rawQuery()

b)

getColumnIndexOrThrow()

c)

execSQL()

d)

moveToFirst()

7.

When you perform a query with rawQuery(), what type of object is returned to allow you to traverse the results?

a)

ContentValues

b)

SQLiteDatabase

c)

Cursor

d)

ResultSet

8.

What does the moveToFirst() method do on a Cursor object?

a)

Closes the Cursor to free up resources

b)

Moves the Cursor to the last row in the result set

c)

Moves the Cursor to the first row in the result set

d)

Inserts a new row at the beginning of the table

9.

Which class is essentially a set of key-value pairs used for binding data when inserting or updating database records?

a)

Cursor

b)

Bundle

c)

ContentValues

d)

Intent

10.

Which SQL statement would you use to add a new column named 'Email' to an existing table called 'Profile'?

a)

UPDATE Profile SET Email = ...

b)

INSERT INTO Profile (Email) VALUES ...

c)

ALTER TABLE Profile ADD Email VARCHAR(50);

d)

DROP COLUMN Email FROM Profile;

11.

If you want a view inside a GridLayout to span across two rows, what attribute would you primarily use?

a)

android:layout_spanRows

b)

android:rowSpan

c)

android:layout_rowSpan

d)

android:spanRowCount

12.

What is the main advantage of using a CardView over a simple LinearLayout for displaying a contact's information?

a)

It automatically connects to a SQLite database

b)

It provides a modern look with shadows and rounded corners without custom drawing

c)

It can only contain other CardViews

d)

It improves the performance of database queries

13.

Which of the following SQL commands is a Data Definition Language (DDL) command, based on the examples provided?

a)

SELECT

b)

INSERT

c)

ALTER

d)

UPDATE

14.

The execSQL(String sql, Object[] bindArgs) method is safer than the basic execSQL(String sql) method for INSERT operations because it:

a)

Executes the query faster

b)

Automatically creates the database if it doesn't exist

c)

Helps protect against SQL injection by using bind arguments

d)

Does not require a Cursor to read the results

15.

After retrieving a Cursor from rawQuery(), what method should you always call when you are finished using it?

a)

moveToFirst()

b)

getCount()

c)

close()

d)

isAfterLast()

16.

What is the purpose of the getColumnIndexOrThrow(String) method of the Cursor class?

a)

To get the number of rows in the Cursor

b)

To get the index number of a column based on its name, and throw an exception if the column doesn't exist

c)

To insert a new column into the database table

d)

To move the Cursor to a specific row index

17.

You want to insert a new student into your 'StudentRecord' table using the insert() method. What is the correct type for the second parameter of this method?

a)

String[] (an array of strings)

b)

Cursor

c)

ContentValues

d)

SQLiteDatabase

18.

Which method would you use to check if you have reached the end of the results while looping through a Cursor?

a)

moveToNext()

b)

isAfterLast()

c)

getCount()

d)

isLast()

19.

What does the MODE_PRIVATE constant signify when calling openOrCreateDatabase?

a)

The database can be read and written by other applications

b)

The database file is encrypted

c)

The created database will be accessible only to your application

d)

The database is opened in read-only mode

20.

Based on the notes, what is the direct result of executing this SQL statement? ALTER TABLE Profile DROP COLUMN Movie;

a)

Deletes all data from the 'Movie' column

b)

Deletes the entire 'Profile' table from the database

c)

Permanently removes the 'Movie' column from the 'Profile' table

d)

Renames the 'Movie' column