JSP Java Interview Questions – Set 07

How can I set a cookie and delete a cookie from within a JSP page Cookie mycook = new Cookie(“name”,”value”); response.addCookie(mycook); Cookie killmycook = new Cookie(“mycook”,”value”); killmycook.setMaxAge(0); killmycook.setPath(“/”); killmycook.addCookie(killmycook); What is JavaServer Pages Standard Tag Library (JSTL A tag library that encapsulates core functionality common to many JSP applications.JSTL has support for common, structural tasks … Read more

Core Java Interview Questions – Set 07

What is the difference between preemptive scheduling and time slicing Under preemptive scheduling, the highest priority task executes until it enters the waiting or dead states or a higher priority task comes into existence. Under time slicing, a task executes for a predefined slice of time and then reenters the pool of ready tasks. The … Read more

Servlet Java Interview Questions – Set 07

When init() and Distroy() will be called init() is called whenever the servlet is loaded for the first time into the webserver.it performs certain one time activities which are required during the lifetime of the servlet.It may be some initialisation of variables or a database connection. Destroy will be called whenever the servlet is removed … Read more

Interface Java Interview Questions – Set 07

What is a Session? Can you share a session object between different threads Session is a light weight and a non-threadsafe object (No, you cannot share it between threads) that represents a single unit-of-work with the database. Sessions are opened by a SessionFactory and then are closed when all work is complete. Session is the … Read more

Multi Threading Java Interview Questions – Set 07

How will you fix the above racing issue This can be fixed a number of ways. Option 1: Method level synchronization. This is the simplest. As you can see, the increment() method is synchronized, so that the other threads must wait for the thread that already has the lock to execute that method. import java.util.HashMap; import … Read more

Core Java Interview Questions – Set 06

What is the difference between the Reader/Writer class hierarchy and the InputStream/OutputStream class hierarchy The Reader/Writer class hierarchy is character-oriented, and the InputStream/OutputStream class hierarchy is byte-oriented. How is an argument passed in java, by copy or by reference What is a modulo operator This operator gives the value which is related to the remainder of a divisione.g x=7%4 … Read more

JSP Java Interview Questions – Set 06

What is JSP directive A JSP element that gives an instruction to the JSP container and is interpreted at translation time. How will you handle the runtime exception in your jsp page The errorPage attribute of the page directive can be used to catch run-time exceptions automatically and then forwarded to an error processing page. … Read more

Exception Handling Java Interview Questions – Set 06

When do we say an exception is not handled There is no catch block that names either the class of exception that has been thrown or a class of exception that is a parent class of the one that has been thrown, then the exception is considered to be unhandled, in such condition the execution … Read more

Servlet Java Interview Questions – Set 06

Difference between JSP include directive and JSP include action <%@ include file=”filename” %> is the JSP include directive.At JSP page translation time, the content of the file given in the include directive is ‘pasted’ as it is, in the place where the JSP include directive is used. Then the source JSP page is converted into … Read more

Interface Java Interview Questions – Set 06

When can an object reference be cast to an interface reference An object reference be cast to an interface reference when the object implements the referenced interface. What is a cloneable interface and how many methods does it contain ?– It is not having any method because it is a TAGGED or MARKER interface. What … Read more