HTML Questions & Answers – Web Databases

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?
a) prepareDatabase()
b) showDocCount()
c) executeSql()
d) openDatabase()
View Answer

Answer: a
Explanation: prepareDatabase() function is used to return a handle to database. It is necessary to first create the database. showDocCount() shows the real work after creating the database. Syntax of calling a JavaScript function is: function prepareDatabase(ready, error).

2. openDatabase() method does not take the argument in __________
a) database name
b) display name
c) database version
d) server name
View Answer

Answer: d
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 _____________
a) &
b) *
c) ^
d) ?
View Answer

Answer: d
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.

advertisement
advertisement

4. Which feature is not used when SQL features are not being supported?
a) BEGIN
b) END
c) COMMIT
d) ROLLBACK
View Answer

Answer: b
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 _______
a) callback
b) success callback
c) error callback
d) database name
View Answer

Answer: d
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?
a) changeVersion()
b) readTransaction()
c) transaction()
d) executeSql()
View Answer

Answer: a
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?
a) INVALID_ACCESS_ERR
b) UNKNOWN_ERR
c) TIMEOUT_ERR
d) INVALID_STATE_ERR
View Answer

Answer: d
Explanation: When SQLTransactionCallback, SQLStatementErrorCallback, SQLStatementCallback does not execute then INVALID_STATE_ERR error is raised. This error is raised from inside a SQLTransactionErrorCallback.
advertisement

8. Which object is created for read-only transaction?
a) Foo object
b) SQLTransactionSync
c) DatabaseSync object
d) SQLTransaction
View Answer

Answer: b
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
View Answer

Answer: b
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.
advertisement

10. Number of rows is returned by the attribute __________
a) insertIID
b) rows
c) rowsAffected
d) length
View Answer

Answer: c
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?
a) TOO_LARGE_ERR
b) UNKNOWN_ERR
c) TIMEOUT_ERR
d) QUOTA_ERR
View Answer

Answer: a
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
View Answer

Answer: a
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?
a) results.rows.item(i)
b) insertId
c) rowAffected
d) length
View Answer

Answer: a
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.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.