This set of HTML Multiple Choice Questions & Answers (MCQs) focuses on “Web Databases”.
1. Which function is used to return a handle to the database?
2. openDatabase() method does not take the argument in __________
a) database name
b) display name
c) database version
d) server name
Explanation: openDatabase() and openDatabaseSync() methods takes the name of the database, version of the database, display name, estimated size in bytes of the data that is to be stored in the database. openDtabase() method works on WorkerUtils and Window, openDatabaseSync() method works on WorkerUtils.
3. The sign is used for the placeholder _____________
Explanation: ‘?’ is used for the placeholder. Binding of the ? placeholder is done at a literal level. It is dynamically inserted into the statement. ‘?’ can be used in place of literals in SQL statements. If this character is not supported then the error code 5 is invoked.
4. Which feature is not used when SQL features are not being supported?
Explanation: When SQL feature is not supported then we use COMMIT, BEGIN, ROLLBACK SQL features and are marked as bogus. User agent uses the statements that contain these three words in case of failure of the support of SQL features.
5. transaction() does not take the argument _______
b) success callback
c) error callback
d) database name
Explanation: transction() and readTransaction() are the two methods that take three arguments i.e. transaction callback as the first argument, error callback as the second argument, success callback as the third argument.
6. Which method is used to verifythe version number?
Explanation: changeVersion() method automatically verify version number and it also changes it like doing a schema update. When this method is invoked it immediately returns and then run transaction steps asynchronously by taking transaction callback as the third argument, error callback as the fourth argument and success callback as the fifth argument.
7. Which error is invoked when SQLTransactionCallback does not execute?
Explanation: When SQLTransactionCallback, SQLStatementErrorCallback, SQLStatementCallback does not execute then INVALID_STATE_ERR error is raised. This error is raised from inside a SQLTransactionErrorCallback.
8. Which object is created for read-only transaction?
a) Foo object
c) DatabaseSync object
Explanation: For read-only transaction, we create the object SQLTransactionSync. If the first argument is NULL then we throw SQLException which is Error code 0. SQLTransactionSync object is fresh initially but when it is marked as stale it is committed or rolled back.
9. insertId attribute returns ____________
a) column ID
b) row ID
c) user’s ID
d) database ID
Explanation: insertId attribute returns the row ID of the row of the inserted SQLResultSet object’s SQL statement that is inserted into the database. If multiple rows are inserted then the ID of the last row will be returned. If there is no row then INVALID_ACCESS_ERR exception will be raised.
10. Number of rows is returned by the attribute __________
Explanation: rowsAffected attribute returns the number of rows that were changed by SQL. If there is no change by the SQL statement then this attribute will return zero. If we use “SELECT” statement, this attribute will always return zero.
11. Which of the error is raised when the quantity of data is too much?
Explanation: When the quantity of the data returned from the database is very large then TOO_LARGE_ERR is invoked. To minimize the data we can use SQL “LIMIT” i.e. modifier to reduce the size of the resultant set.
12. What is the required argument to openDatabase?
a) version number
b) database name
c) size of a database
d) text description
Explanation: The required argument to openDatabase is version number. So it is mandatory that you should know the version number before we try to open the database. If we do not pass this argument then an exception is thrown.
13. Which attribute is used for getting an individual row?
Explanation: For getting individual row results.rows.item(i) is used, i denotes the index of the row. It will return the object representation of the row. insertId returns row id but in case of multiple rows, it returns the id of the last row.
Sanfoundry Global Education & Learning Series – HTML.
To practice all areas of HTML, here is complete set of 1000+ Multiple Choice Questions and Answers.