Posts

Part1 Threading Interview Questions and Answers

1) What is Daemon thread ? Daemon thread are background threads which are used for background task. JVM do not care for background thread execution. Once all other non Daemon threads completes their executions and JVM ends without caring for the running Daemon threads. One can make a non-daemon thread a daemon thread using the .setDaemon(true) method. One can check thread is daemon or not using the isDaemon() method. Mostly JVM creates daemon threads for Garbage collection related background task. 2) What is Mutex ? Mutex are used to serialise access of a particular section of code that cannot be executed simultaneously  by more than one thread. A mutex object only allows one thread into a controlled code area, It force other threads which are attempting to gain access to that controlled section to wait until the first thread is exited from that controlled section.

Part3 - JSP and Servlet Questions

1} Why is _jspServic e () start with ‘_’? Ans: _jspService() method will be written by the container hence any methods which are not to be overridden bythe end user are typically written starting with a '_'. T his is the reason why we don't override _jspService()  method in any JSP page. 2} How to pre-c ompile jsp? Ans: Add jsp_precompile as a request parameter and send a request to the JSP file. T his will make the jsp pre- compile. http://localhost:8080/jsp1/test.jsp?jsp_precompile=true It causes execution of JSP life cycle until jspInit() method without executing _jspService() method. 3} What is the benefit of pre-c ompile jsp page? Ans: It removes the start-up lag that occurs when a container must translate a JSP page upon receipt of the first  request. 4} What is the difference between variable declared inside the declaration tag and variable  declared in scriptlet? Ans: Variable declared inside declaration part is treated as a instance variable and will be ...

Part2 - JSP and Servlet Questions

1} What is the <load-on-startup> element? Ans: The <load-on-startup> element of a deployment descriptor is used to load a servlet file when the server  starts instead of waiting for the first request. It is also used to specify the order in which the files are to be loaded. 2} What is session? Ans: A session refers to all the requests that a sing le client mig ht make to a server in the course of viewing any  pag es associated with a g iven application. Sessions are specific to both the individual user and the application. 3} What is the session tracking ? Ans: Session tracking is a mechanism that servlets use to maintain state about a series of requests from the same  user (requests orig inating from the same browser) across some period of time. 4} What is the need of session trac king in web application? Ans: HT T P is a stateless protocol. Every request is treated as new request. For web applications to be more  realistic they have to retain in...

Part1 - JSP and Servlet Questions

1} What is JSP? Ans : Java Server Pages technology (JSP) is used to create dynamic web page. It is an extension to the servlet technology. A JSP page is internally converted into servlet. 2} What are the life-cycle methods for a jsp? Ans: public void jspInit() It is invoked only once, same as init method of servlet. public void _jspService(ServletRequest request,ServletResponse)throws ServletException,IOException It is invoked at each request, same as service() method of servlet. public void jspDestroy() It is invoked only once, same as destroy() method of servlet. 3} What are the JSP implicit objects ? Ans: JSP provides 9 implicit objects by default. They are as follows: Object (Its Type) 1) out (JspWriter) 2) request (HttpServletRequest) 3) response (HttpServletResponse) 4) config (ServletConfig) 5) session (HttpSession) 6) application (ServletContext) 7) pageContext (PageContext) 8) page (Object) 9) exception (Throwable) 4} What is servlet? A: A servlet ...

Part1 - Hibernate Q and A

1.What is ORM ? ORM stands for object/relational mapping. ORM is the automated persistence of objects in a Java application to the tables in a relational  database. 2.What does ORM consists of ? An ORM solution consists of the followig four pieces: API for performing basic CRUD operations API to express queries refering to classes Facilities to specify metadata  Optimization facilities : dirty checking,lazy associations fetching. 3.What are the ORM levels ? The ORM levels are: Pure relational (stored procedure.) Light objects mapping (JDBC) Medium object mapping Full object Mapping (composition,inheritance, polymorphism, persistence by reachability). 4.What is Hibernate? Hibernate is a pure Java object-relational mapping (ORM) and persistence framework that allows you to map plain old Java objects to  relational database tables using (XML) configuration files.Its purpose is to relieve the developer from a significant amount of relational  data persi...