Advanced Java Programming (3160707) MCQs

MCQs of Servlet API and Overview

Showing 1 to 10 out of 57 Questions
1.
_____ is responsible to create the object of servlet?
(a) web container
(b) servlet container
(c) both A & B
(d) only B
Answer:

Option (c)

2.
When servlet object is created? (select the correct option)
i) When the application begins.
ii) When servlet is first accessed.
iii) When init() of the servlet is called.
iv) When service() of the servlet is called.
v) When run() of Servlet is called
(a) i) and ii)
(b) i),ii) and iii)
(c) i),iii) and iv)
(d) only v)
Answer:

Option (b)

3.
What happens if you add a main method to servlet?
(a) It will give an error.
(b) Program will start execution with main method without any error.
(c) No error but this method will not get executed automatically.
(d) main method will be executed automatically after service method().
Answer:

Option (c)

4.
What is MIME Type?
(a) Multiple Internet Mail Extension
(b) Multiple Intranet Mail Extension
(c) Multipurpose Internet Mail Expansion
(d) Multipurpose Internet Mail Extension
Answer:

Option (d)

5.
Consider a scenario in which 4 users are accessing a servlet instance. Among which one user called destroy() method. What happens to the rest 3 users?
(a) All the 4 users get terminated. Servlet will be available to garbage collector.
(b) only one user that calls destroy(),will be terminated. Rest 3 remain connected with servlet.
(c) It will generate runtime error.
(d) only one user can access a servlet at a time, so this is invalid state.
Answer:

Option (b)

6.
Is there any constructor in Servlet?
(a) Yes, servlet is java class, thus it contain constructor.
(b) No constructor because Servlet is web class and not java class.
(c) It will give run time error if you write constructor in servlet.
(d) It can have constructor but it is not the right way to initialize servlet.
Answer:

Option (d)

7.
In servlet each request from client is handled by _____
(a) Process
(b) Thread
(c) OS
(d) Both A & B
Answer:

Option (b)

8.
Which method is called only once in life cycle of servlet?
i) init()
ii) service()
iii) destroy()
(a) i) & ii)
(b) i) & iii)
(c) ii) & iii)
(d) All the three
Answer:

Option (b)

9.
_____ is the parent class of java servlet.
(a) Servlet
(b) GenericServlet
(c) HttpServlet
(d) ServletConfig
Answer:

Option (b)

10.
_____ is the parent interface of java servlet.
(a) Servlet
(b) ServletConfig
(c) ServletContext
(d) HttpServlet
Answer:

Option (a)

Showing 1 to 10 out of 57 Questions