Oracle Java Interview Questions & Answers Set-10

«« Previous
Next »»

181) What does the JDBC ResultSet interface?
Ans: The ResultSet object represents a row of a table. It can be used to change the cursor pointer and get the information from the database.


182) What does the JDBC ResultSetMetaData interface?
Ans: The ResultSetMetaData interface returns the information of table such as total number of columns, column name, column type etc.


183) What does the JDBC DatabaseMetaData interface?
Ans: The DatabaseMetaData interface returns the information of the database such as username, driver name, driver version, number of tables, number of views etc.


184) Which interface is responsible for transaction management in JDBC?
Ans: The Connection interface provides methods for transaction management such as commit(), rollback() etc.


185) What is batch processing and how to perform batch processing in JDBC?
Ans: By using batch processing technique in JDBC, we can execute multiple queries. It makes the performance fast.


186) How can we store and retrieve images from the database?
Ans: By using PreparedStatement interface, we can store and retrieve images.


Jsp Interview questions



187) 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.


188) What are the life-cycle methods for a jsp?
Ans: 
Method
Description
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.


189) What is difference between hide comment and output comment?
Ans: The jsp comment is called hide comment whereas html comment is called output comment. If user views the source of the page, the jsp comment will not be shown whereas html comment will be shown.


190) What are the JSP implicit objects ?
Ans: JSP provides 9 implicit objects by default. They are as follows:

Object
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


191) What is difference between include directive and include action?
Ans: 
include directive
include action
1) The include directive includes the content at page translation time. 1) The include action includes the content at request time.
2) The include directive includes the original content of the page so page size increases at runtime.2) The include action doesn't include the original content rather invokes the include() method of Vendor provided class.
3) It's better for static pages.3) It's better for dynamic pages.


192) Is JSP technology extensible?
Ans: Yes. JSP technology is extensible through the development of custom actions, or tags, which are encapsulated in tag libraries.


193) How can I implement a thread-safe JSP page? What are the advantages and Disadvantages of using it?
Ans: You can make your JSPs thread-safe by having them implement the SingleThreadModel interface. This is done by adding the directive <%@ page isThreadSafe="false" %> within your JSP page.


194) How can I prevent the output of my JSP or Servlet pages from being cached by the browser?
(OR) How to disable caching on back button of the browser?
Ans:
<%
response.setHeader("Cache-Control","no-store");
response.setHeader("Pragma","no-cache");
response.setHeader ("Expires", "0"); //prevents caching at the proxy server
%>


195) How can we handle the exceptions in JSP ?
Ans: There are two ways to perform exception handling, one is by the errorPage element of page directive, and second is by the error-page element of web.xml file.


196) What are the two ways to include the result of another page. ?
Ans: There are two ways to include the result of another page:

  • By include directive
  • By include action

197) How can we forward the request from jsp page to the servlet ?
Ans: Yes ofcourse! With the help of forward action tag, but we need to give the url-pattern of the servlet.


198) Can we use the exception implicit object in any jsp page ?
Ans: No. The exception implicit object can only be used in the error page which defines it with the isErrorPage attribute of page directive.


199) How is JSP used in the MVC model?
Ans: JSP is usually used for presentation in the MVC pattern (Model View Controller ) i.e. it plays the role of the view. The controller deals with calling the model and the business classes which in turn get the data, this data is then presented to the JSP for rendering on to the client.


200) What are context initialization parameters?
Ans:  Context initialization parameters are specified by the <context-param> in the web.xml file, these are initialization parameter for the whole application and not specific to any servlet or JSP.

«« Previous
Next »»