Machine-translated by Google. Questions are authored in English.
Top

JDBC, Java Server Pages, and MySQL Questions and Answers

1.

Which Servlet life-cycle method is called only once ?

Exam Year(s)

Tripura Public Service Commission - 2026,

Answer: A

The keyed answer is init().

The servlet container calls init() exactly once, after it creates the servlet object and before the first request, to let the servlet set itself up. service() (the printed option reads services()) and the handlers doGet() and doPost() run once for every request.

One caution: destroy() is also called only once, when the container removes the servlet. The question does not exclude it, but the key and the usual textbook answer to 'called only once' is init(), the one-time initialisation method, so that is the answer given.

Please log in or register to report this question.

2.

When a servlet cannot be instantiated by the servlet container, which exception is thrown to the servlet container methods such as init() or service() ?

Exam Year(s)

Tripura Public Service Commission - 2026,

Answer: D

The answer is None of these.

In the Servlet API, the life-cycle methods signal failure with ServletException and its subclass UnavailableException, which tells the container that the servlet cannot be put into service, temporarily or permanently. Neither is offered.

InstantiationException is a general Java reflection exception raised when a class cannot be instantiated; it is not what init() or service() throw. ServletInitializationException is not a class in the Servlet API. IllegalStateException is thrown when a method is called at the wrong time, for example sending a redirect after the response has been committed.

Please log in or register to report this question.

3.

An applet is a Java bytecode program that is sent to the user via HTTP and is invoked using the HTTP protocol on the user's computer.

Answer: A

Correct answer: True

That is the definition of an applet, and the contrast with a servlet is the point: an applet is sent over HTTP and executed by the JVM in the user’s browser, a servlet is executed by the container on the server. The applet’s dependence on a browser JVM is what eventually made it obsolete.

Please log in or register to report this question.

Answer: C

Correct answer: It may have many constructors as necessary.

A bean must provide a public constructor taking no arguments, because the container creates it by reflection and has no arguments to supply. Additional constructors may exist, but the no-argument one is obligatory, so the statement as written is not true of a bean. The other two - no public instance variables, access through get and set methods - are the other defining requirements.

Please log in or register to report this question.

5.

JSP and ASP not only look alike but their underlying technology is quite similar.

Answer: B

Correct answer: False

They look alike on the page, both embedding code in HTML, and there the resemblance ends. JSP is translated into a Java servlet and runs on the JVM in a servlet container; ASP runs under the Microsoft web server and accepts VBScript and JScript rather than Java. The similarity is of appearance only.

Please log in or register to report this question.

6.

MySQL is pronounced "my See-quel."

Answer: B

Correct answer: False

It is pronounced My Ess Cue Ell, letter by letter, and the manual says so explicitly. The See-quel pronunciation belongs to SQL Server and to SQL informally, and the distinction is a point the MySQL documentation has always been particular about.

Please log in or register to report this question.

7.

Which JDBC driver Types are for use over communications networks?

Answer: C

Correct answer: Both Type 3 and Type 4

Types 3 and 4 are pure Java and communicate over a network, Type 3 to a middleware server and Type 4 straight to the DBMS in its own protocol. Neither needs anything installed on the client, which is what makes them the types usable from applets and from servlets on machines separate from the database.

Please log in or register to report this question.

8.

MySQL surrogate keys are given the property AUTO_INCREMENT.

Answer: A

Correct answer: True

AUTO_INCREMENT on an integer column makes MySQL supply the next value automatically on each insert, which is precisely what a surrogate key needs: a unique value with no meaning, generated by the system rather than by the application.

Please log in or register to report this question.

9.

JDBC Type 2 drivers connect to the native API of the DBMS.

Answer: A

Correct answer: True

A Type 2 driver converts JDBC calls into calls on the DBMS vendor’s own client library, so part of it is native code that must be installed on the machine. It is generally faster than the Type 1 bridge for that reason, and less portable for the same one.

Please log in or register to report this question.

10.

How many copies of a JSP page can be in memory at a time?

Answer: A

Correct answer: One

The container keeps a single instance of the translated servlet and serves every concurrent request from it, each on its own thread. This is why a JSP must be written to be thread-safe: an instance variable is shared across all users, and only local variables within the service method are private to a request.

Please log in or register to report this question.

Loading…

Other Subjects

Tags: JDBC, Java Server Pages, and MySQL Questions and Answers || JDBC, Java Server Pages, and MySQL MCQ Questions and Answers || JDBC, Java Server Pages, and MySQL GK Questions and Answers || JDBC, Java Server Pages, and MySQL GK MCQ Questions || JDBC, Java Server Pages, and MySQL Multiple Choice Questions and Answers || JDBC, Java Server Pages, and MySQL GK || GK on JDBC, Java Server Pages, and MySQL || Database Questions and Answers || Database MCQ Questions and Answers || Database GK Questions and Answers || GK on Database