Java FAQ

We offer you quality collection of Java FAQ from core java, jsp and servlet. These java FAQ will help you to prepare for career java interview, java certification, college tests and campus interview. It will also help to update your java knowledge.

Recently Added Questions:

What happens if you call destroy() from init() in java servlet?

destroy() gets executed and the initialization process continues. It is a trick question in servlets interview. In java servlet, destroy() is not supposed to be called by the programmer. But, if it is invoked, it gets executed. The implicit question is, will the servlet get destroyed? No, it will not. destroy() method is not supposed to and will...

Explain the final keyword in java.

A java variable can be declared using the keyword final. Then the final variable can be assigned only once. A variable that is declared as final and not initialized is called a blank final variable. A blank final variable forces the constructors to initialise it. Java classes declared as final cannot be extended. Restricting inheritance! Methods declared as final cannot be overridden. In ...

Access modifiers in java - explain.

Access modifiers specifies who can access them. There are four access modifiers used in java. They are public, private, protected, no modifer (declaring without an access modifer). Using 'no modifier' is also sometimes referred as 'default' or 'friendly' access. Usage of these access modifiers is restricted to two levels. The two levels are class level access modifier and member level access modi...

How to avoid IllegalStateException in java servlet?

The root cause of IllegalStateException exception is a java servlet is attempting to write to the output stream (response) after the response has been committed. It is always better to ensure that no content is added to the response after the forward or redirect is done to avoid IllegalStateException. It can be done by including a 'return' state...

What is servlet mapping?

Servlet mapping specifies the web server which java servlet should be invoked for a given url. It maps url patterns to servlet and it is given in the web deployment descriptor web.xml. servlet-mapping has two child tags, url-pattern and servlet-name. url-pattern specifies the type of urls for which, the servlet given in servlet-name should be called. One pattern, which equals multiple urls can map...

Difference between HttpServlet and GenericServlet

javax.servlet.GenericServlet Signature: public abstract class GenericServlet extends java.lang.Object implements Servlet, ServletConfig, java.io.Serializable GenericServlet defines a generic, protocol-independent servlet. GenericServlet gives a blueprint and makes writing servlet easier. GenericServlet provides simple versions of the lifec...