Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Charles Lyon's book mock exam 3

 
Himai Minh
Ranch Hand
Posts: 1361
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On p. 62, question 10 of Charles Lyon's book,

Which abstract class or interface must be extended or implemented to provide an HTTP servlet?
A. javax.servlet.Servlet (interface).
B. javax.servlet.GenericServlet (interface)
C. javax.servlet.GenericServlet(abstract class)
D.javax.servlet.http.HttpServlet (abstract class)
E. javax.servlet.http.GenericHttpServlet(abstract class)

The given answer is A. The explanation:

Correct answer A.
Only Servlet must ever be implemented - the others are just convenient classes. The appropriate (but optional) classes to use are C if you want a protocol independent servlet , or D for an HTTP specific servlet.


But I think the correct answer should be D : HttpServlet.
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2536
113
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why? Don't you agree with the explanation?
 
Himai Minh
Ranch Hand
Posts: 1361
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In most examples provided by Head First, I see the servlets extends HttpServlet and overrides the Http methods such as doGet and doPost.
I don't think the servlet implements Servlet interface directly.
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2536
113
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In most examples provided by Head First, I see the servlets extends HttpServlet and overrides the Http methods such as doGet and doPost.

That is true, but this is more of a theoretical question (and a bit far-fetched I must agree).

In order to implement an HTTP Servlet you must implement the Servlet interface. The HttpServlet is just a helper class (and very convenient indeed) to make things easier for us. You could leave out using the GenericServlet and the HttpServlet class and still being able to implement an HTTP Servlet.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic