NEW
Font size
WorksheetsAndroid Database and Layout Quiz
Total questions: 20
Worksheet time: 10mins
What is the primary function of a GridLayout in Android?
To display data from a SQLite database
To create layouts with rounded corners and shadows
To place its children in a rectangular grid of rows and columns
To execute SQL queries
Which of the following is a key feature of CardView?
It automatically creates SQLite tables
It executes the execSQL method
It provides rounded corners and elevation (shadow)
It defines the number of rows and columns for a database
Which package contains the classes to manage your own SQLite databases in Android?
android.view
android.content
android.database.sqlite
android.widget
Which SQL command is used to change a value in one or more existing rows of a table?
INSERT
SELECT
DELETE
UPDATE
What is the purpose of the openOrCreateDatabase method in Android?
It only opens an existing database in read-only mode
It opens an existing database and creates it if it does not exist
It is used to insert new rows into a table
It closes the database connection
Which method is commonly used to execute a SQL statement that creates a table or inserts data?
rawQuery()
getColumnIndexOrThrow()
execSQL()
moveToFirst()
When you perform a query with rawQuery(), what type of object is returned to allow you to traverse the results?
ContentValues
SQLiteDatabase
Cursor
ResultSet
What does the moveToFirst() method do on a Cursor object?
Closes the Cursor to free up resources
Moves the Cursor to the last row in the result set
Moves the Cursor to the first row in the result set
Inserts a new row at the beginning of the table
Which class is essentially a set of key-value pairs used for binding data when inserting or updating database records?
Cursor
Bundle
ContentValues
Intent
Which SQL statement would you use to add a new column named 'Email' to an existing table called 'Profile'?
UPDATE Profile SET Email = ...
INSERT INTO Profile (Email) VALUES ...
ALTER TABLE Profile ADD Email VARCHAR(50);
DROP COLUMN Email FROM Profile;
If you want a view inside a GridLayout to span across two rows, what attribute would you primarily use?
android:layout_spanRows
android:rowSpan
android:layout_rowSpan
android:spanRowCount
What is the main advantage of using a CardView over a simple LinearLayout for displaying a contact's information?
It automatically connects to a SQLite database
It provides a modern look with shadows and rounded corners without custom drawing
It can only contain other CardViews
It improves the performance of database queries
Which of the following SQL commands is a Data Definition Language (DDL) command, based on the examples provided?
SELECT
INSERT
ALTER
UPDATE
The execSQL(String sql, Object[] bindArgs) method is safer than the basic execSQL(String sql) method for INSERT operations because it:
Executes the query faster
Automatically creates the database if it doesn't exist
Helps protect against SQL injection by using bind arguments
Does not require a Cursor to read the results
After retrieving a Cursor from rawQuery(), what method should you always call when you are finished using it?
moveToFirst()
getCount()
close()
isAfterLast()
What is the purpose of the getColumnIndexOrThrow(String) method of the Cursor class?
To get the number of rows in the Cursor
To get the index number of a column based on its name, and throw an exception if the column doesn't exist
To insert a new column into the database table
To move the Cursor to a specific row index
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?
String[] (an array of strings)
Cursor
ContentValues
SQLiteDatabase
Which method would you use to check if you have reached the end of the results while looping through a Cursor?
moveToNext()
isAfterLast()
getCount()
isLast()
What does the MODE_PRIVATE constant signify when calling openOrCreateDatabase?
The database can be read and written by other applications
The database file is encrypted
The created database will be accessible only to your application
The database is opened in read-only mode
Based on the notes, what is the direct result of executing this SQL statement? ALTER TABLE Profile DROP COLUMN Movie;
Deletes all data from the 'Movie' column
Deletes the entire 'Profile' table from the database
Permanently removes the 'Movie' column from the 'Profile' table
Renames the 'Movie' column
