Database Questions and Answers – Servlets and JSP

This set of Database Multiple Choice Questions & Answers (MCQs) focuses on “Servlets and JSP”.

1. The Java __________ specification defines an application programming interface for communication between the Web server and the application program.
a) Servlet
b) Server
c) Program
d) Randomize
View Answer

Answer: a
Explanation: Servlets are commonly used to generate dynamic responses to HTTP requests.

2. The doGet() method in the example extracts values of the parameter’s type and number by using __________
a) request.getParameter()
b) request.setParameter()
c) responce.getParameter()
d) responce.getAttribute()
View Answer

Answer: a
Explanation: These methods uses these values to run a query against a database.

3. How many JDBC driver types does Sun define?
a) One
b) Two
c) Three
d) Four
View Answer

Answer: d
Explanation: JBDB.DriverManager.getConnection() is used to get the connection to the database.
advertisement
advertisement

4. Which JDBC driver Type(s) can be used in either applet or servlet code?
a) Both Type 1 and Type 2
b) Both Type 1 and Type 3
c) Both Type 3 and Type 4
d) Type 4 only
View Answer

Answer: c
Explanation: In a Type 3 driver, a three-tier approach is used to accessing databases. The JDBC clients use standard network sockets to communicate with an middleware application server. In a Type 4 driver, a pure Java-based driver that communicates directly with vendor’s database through socket connection.

5. What MySQL property is used to create a surrogate key in MySQL?
a) UNIQUE
b) SEQUENCE
c) AUTO_INCREMENT
d) None of the mentioned
View Answer

Answer: c
Explanation: A surrogate key in a database is a unique identifier for either an entity in the modeled world or an object in the database.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

6. A JSP is transformed into a(n):
a) Java applet
b) Java servlet
c) Either 1 or 2 above
d) Neither 1 nor 2 above
View Answer

Answer: b
Explanation: Servlets are commonly used to generate dynamic responses to HTTP requests.

7. Which JDBC driver Type(s) is(are) the JDBC-ODBC bridge?
a) Type 1
b) Type 2
c) Type 3
d) Type 4
View Answer

Answer: a
Explanation: In a Type 1 driver, a JDBC bridge is used to access ODBC drivers installed on each client machine.
advertisement

8. What programming language(s) or scripting language(s) does Java Server Pages (JSP) support?
a) VBScript only
b) Jscript only
c) Java only
d) All of the mentioned
View Answer

Answer: c
Explanation: JSP primarily uses Java for certain codes.

9. What is bytecode?
a) Machine-specific code
b) Java code
c) Machine-independent code
d) None of the mentioned
View Answer

Answer: c
Explanation: Java bytecode is the form of instructions that the Java virtual machine executes. Each bytecode opcode is one byte in length, although some require parameters, resulting in some multi-byte instructions.
advertisement

10. Where is metadata stored in MySQL?
a) In the MySQL database metadata
b) In the MySQL database metasql
c) In the MySQL database mysql
d) None of the mentioned
View Answer

Answer: c
Explanation: Metadata contains data about other data which is given in the <meta>…</meta> tags.

Sanfoundry Global Education & Learning Series – Database Management System.

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.