Sun Certified Web Component Developer Practice Questions

    Previous   Next      
Q. No Question
11 What will be the output of the following JSP code?
<html><body>  <%! int a = 20; %> <% int a = 10; %> <%! int b = 30; %> Now b = <%= b * a %> </body></html>
 
  A Now b = 300
  B Now b = 600
  C The code will not compile
  D Now b = 30
  E Now b = 0
   
  Answer
12 Consider the following code snippet of servlet code:
public void doGet (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        PrintWriter out = response.getWriter();
        String value = getValue ();
        if (value == null) response.sendError (HttpServletResponse.SC_NOT_FOUND, "Failed");            

        response.sendRedirect ("test.jsp");
}
If the getValue () method returns null , which of the following statements are true?
 
  A The code will work without any errors or exceptions
  B An IllegalStateException will be thrown
  C An IOException will be thrown
  D A NullPointerException will be thrown
   
  Answer
13 Which of the following can be used to configure the JSP container to ignore EL expressions? 
 
  A <%@ page isELIgnored="true" %>
  B <%@ page isELIgnored="false" %>
  C <%@ import isELIgnored="false" %>
  D None of the above.
   
  Answer
14 What is the default scope for <jsp:useBean>
 
  A application
  B session
  C page
  D request
   
  Answer
15 Which of the following is the proper way to include java.util package in your jsp page?
 
  A <%@page:import package="java.util">
  B <%@ page import = "java.util.*" %>
  C <%= import java.util.*; %>
  D <%@ page import="java.util.*" %>
   
  Answer
16 To send binary output to response, which method of HttpServletResponse is used to get the Writer/ Stream object ?
 
  A getStream
  B getWriter
  C getBinaryOutputStream
  D getOutputStream
  E getBinaryStream
   
  Answer
17 <%@ page language ="java" session="false" isErrorPage="false" %>
which of the following JSP implicit object will not be available to the JSP page ? Select two
 
  A session
  B request
  C application
  D exception
   
  Answer
18 Which among the following will compile ?
 
  A <% int x=10 %>
  B <%= "hello how are you" %>
  C <%= "hello" ;% >
  D <%! int x=10 %>
   
  Answer
19 In a JSP custom tag , which method would you use to access JSP implicit variable that references application scope ?
 
  A PageContext.getOut()
  B jspFactory.getPageContext()
  C TagSupport.getValue(String)
  D pageContext.getServletContext()
   
  Answer
20 Which method is used to retrieve objects from session?
 
  A getAttribute method of javax.servlet.ServletSession.
  B getAtrribute method of javax.servlet.HttpSession
  C getAttribute method of javax.servlet.http.Session
  D getAttribute method of javax.servlet.http.HttpSession
  E getAttribute method of javax.servlet.HttpSession
   
  Answer
    Previous   Next