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

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

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

Multi Threading Java Interview Questions – Set 06

What can prevent the execution of the code in finally block ? and what are the rules for catching multiple exceptions? The death of thread – Use of system.exit() – Turning off the power to CPU – An exception arising in the finally block itself Rules for catching multiple exceptions – A more specific catch … Read more

JSP Java Interview Questions – Set 05

Can a JSP page process HTML FORM data Yes. However, unlike Servlet, you are not required to implement HTTP-protocol specific methods like doGet() or doPost() within your JSP page. You can obtain the data for the FORM input elements via the request implicit object within a scriptlet or expression as. Is there a way to … Read more

Servlet Java Interview Questions – Set 05

Explain about ServletConfig Interface ServletConfig a ServletConfig object is used to obtain configuration data when it is loaded. There can be multiple ServletConfig objects in a single web application. This object defines how a servlet is to be configured is passed to a servlet in its init method. Most servlet containers provide a way to … Read more

Multi Threading Java Interview Questions – Set 05

What method is invoked to cause an object to begin executing as a separate thread? The start() method of the Thread class is invoked to cause an object to begin executing as a separate thread. Why do threads block on I/O? Threads block on I/O (that is enters the waiting state) so that other threads may execute while the … Read more

JSP Java Interview Questions – Set 04

What are the life-cycle methods of JSP Life-cycle methods of the JSP are: jspInit(): The container calls the jspInit() to initialize the servlet instance. It is called before any other method, and is called only once for a servlet instance. _jspService(): The container calls the _jspservice() for each request and it passes the request and … Read more

Servlet Java Interview Questions – Set 04

How do you pass data (including JavaBeans) to a JSP from a servlet?- ?– (1) Request Lifetime: Using this technique to pass beans, a request dispatcher (using either “include” or forward”) can be called. This bean will disappear after processing this request has been completed. Servlet: request. setAttribute(”theBean”, myBean); RequestDispatcher rd = getServletContext(). getRequestDispatcher(”thepage. jsp”); … Read more

Multi Threading Java Interview Questions – Set 04

What invokes a thread’s run() method After a thread is started, via its start() method or that of the Thread class, the JVM invokes the thread’srun() method when the thread is initially executed. When a thread is created and started, what is its initial state A thread is in the ready state after it has been created and started. How … Read more