The path is:
YourServlet extends HttpServlet that extends GenericServlet that implements Servlet. Thus, YourServlet implements Servlet
Since you are writing a class, you can talk about constructors.
karthik manick wrote:Servlets are also intefaces rt? then how we have constructors for that? confusing...
Not really: the constructors aren't part of the interface. Classes have constructors. Interfaces don't. *All* classes have constructors (even if it's not explicitly coded by you, there's still a default constructor) regardless of any interfaces it implements.
karthik manick wrote:I read this in a website "Constructor arguments cannot be specified on an interface". Is it so? Please explain why?
Serlets are also interfaces...but i have seen constructors for servlets...contrdicting?
List is an interface, and defines a contract (what methods are available in classes that implement it).
ArrayList is a class, it can be instantiated. It has constructors.
Methods can hide creating instances, and return the interface, just like above. That way, they can hide their internal behaviour, which helps you write code that's easier to maintain: you don't have to worry about the type that's used internally, whether it's an ArrayList, a LinkedList, a CopyOnWriteArrayList or SomeSpecialList.
Same with your servlets.