What will happen inside init() in servlet. my interviewer asked servlet lifecycle. i said "once servlet is loaded in to memory init() will be called which performs servlet initialization " . Again interview asked what values will be initialized . what is difference between init() and init(ServletConfig config).
init() can be tipically called when the server starts or when the servlet is first called, before you handle the request. The server admin or the web application admin can confgure the moment in which method is called.
The only thing that you can count on is that init() is executed before the servlet executes its first request.
You are right, init() is usually called to perform servlet initialization.
About init(ServletConfig config): It's called by the container so you tipically should not override it.