250+ TOP MCQs on Servlets and JSP and Answers

Database Multiple Choice Questions 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

Answer: a
Clarification: 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()

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

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

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

Answer: c
Clarification: 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

Answer: c
Clarification: A surrogate key in a database is a unique identifier for either an entity in the modeled world or an object in the database.

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

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

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

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

Answer: c
Clarification: 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

Answer: c
Clarification: 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.

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

Answer: c
Clarification: Metadata contains data about other data which is given in the… tags.

Leave a Reply

Your email address will not be published. Required fields are marked *