OCEJWCD 6 Mock Questions

Share Embed Donate


Short Description

latest dmps...

Description

OCEJWCD 6 Mock Questions - 1 1. A web.xml for a web application contains the following:

FORM sales /formlogin.html /formerror.html What should formlogin.html contain? Select 1 correct option. A. A base 64 encoded username and password B. A header that prompts the browser to pop up the username/password dialog C. A form that POSTs to j_security_check url D. Any html page that does not require the user to login E. Code to redirect the user to the login page 2. Which of the following are valid values for the element of the deployment descriptor?

Select 2 correct options. A. DIGEST B. CLIENT-CERT C. SECURE D. NONE 3.You want to add third party classes bundled as a JAR file and a couple of your own classes to a web application. Which directories would you place them in?

Select 1 correct option. A. AR file in WEB-INF/lib and class files in WEB-INF/classes B. JAR file in WEB-INF/classes/lib and class files in WEB-INF/classes C. both in WEB-INF/classes D. both in WEB-INF E. JAR file in WEB-INF/jars and class files in WEB-INF/classes 4.Write the name of the deployment descriptor tag that allows you to write a description for a element. Please do not add angle brackets. 5. Which of the following statements are correct?

Select 3 correct options. A. Authorization means determining whether one has access to a particular resource or not B. Authentication means determining whether one has access to a particular resource or not C. Authentication means proving whether one is what one claims to be D. Data Integrity means that the data is not modified in transit between the sender and the receiver E. Data Integrity means that the data cannot be viewed by anybody other than it's intended recipient 6. Your web application named "FWorks" uses SpecialMath.class. This is an unbundled class and is not contained in any jar file. Where will you keep this class file?

Select 1 correct option. A. FWorks/WEB-INF B. FWorks/WEB-INF/classes C. FWorks/WEB-INF/lib/classes

D. FWorks/classes E. FWorks/WEB-INF/lib 7. Which jsp tag can be used to retrieve a property of a bean?

Select 1 correct option. A. jsp:useBean B. jsp:useBean.property C. jsp:useBean.getProperty D. jsp:getProperty E. jsp:property 8. Associate the events with appropriate listener interface:

Drag and drop the matching listener. i. session is activated or passivated ii. session is timed out iii. an attribute is replaced in the session iv. a session is created Select items A.HttpSessionListener B.HttpSessionBindingListener C.HttpSessionActivationListener D.None of these 9. Given the code of doGet() method of a servlet (see exhibit). The data should be sent to the client only if loginUser() returns a non null userid. Otherwise a status of SC_FORBIDDEN should be sent. What can be placed at //1 to fulfill this requirement?

public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { String userId = loginUser(req); //this method takes the credentials from the request and logs in the user. if(userId == null) { // 1 Should send SC_FORBIDDEN } else { PrintWriter out = response.getWriter(); generateAndPublishData(out); //this method writes appropriate date to out. } } Select 3 correct options A. req.getRequestDispatcher("errorpage.jsp").dispatch(req, res, HttpServletResponse.SC_FORBIDDEN); B. throw new ServletException(HttpServletResponse.SC_FORBIDDEN); C. res.setStatus(HttpServletResponse.SC_FORBIDDEN); D. res.sendError(HttpServletResponse.SC_FORBIDDEN, "You are not authorized."); E. res.sendError(HttpServletResponse.SC_FORBIDDEN);

10. Which of the following elements of web.xml affect the whole web application instead of a specific servlet?

Select 1 correct option A.content-type B.init-param C.listener D.application E.app-config 11.Which of the following statements regarding action are correct?

Select 2 correct options. A.It must have an 'id' attribute. B.If 'beanName' attribute is present, 'type' must also be present. C.It must have a 'scope' attribute. D.If 'class' attribute is present, 'type' must also be present. 12. Identify the implicit objects available to EL expressions.

Select 4 correct options A.requestScope B.application C.header D.page E.pageScope F.pageContext 13. Populate the blanks with appropriate examples given in the options.

comment directive declaration scriptlet custom tag expression select the items A. B. C. D. E. F. 14. Which of the following XML fragments correctly defines a role named "manager" in web.xml?

1.manager 2. 3. manager 4. manager A.1 B.2 C.3 D.4 15. Which of the following statements is correct regarding HttpSessionBindingListener interface?

Select 1 correct option. A.The valueBound() method is called BEFORE the object becomes accessible through HttpSession.getAttribute() B.The valueUnbound() method is called BEFORE the object is removed from the

HttpSession C.The valueReplaced() method is called BEFORE the object is replaced with another object in the session D.None of these 16. Consider the following HTML code. Which method of MyFirstServlet will be invoked when you click on the url shown by the page?

Make me say Hello World! Select 1 correct option. A.doGet B.doGET C.post D.doPost E.doPOST 17. Your jsp page connects to the database and retrieves the data. It also formats the data and displays it to the client. Any of these operations can throw exceptions but you do not want to catch them all in this page and so you have written another jsp page that is meant to handle any kind of exceptions. How would you associate that error page named "error.jsp" with this page?

Select 2 correct options. A.Add in this page B.Add in this page C.Add in error.jsp D.Add in error.jsp 18. You have to send a gif image to the client as a response to a request. How will you acquire the 'out' variable to do this?

Select 1 correct option. A.PrintWriter out = response.getPrintWriter(); B.PrintWriter out = response.getWriter(); C.FileOutputStream out = response.getServletOutputStream(); D.ServletOutputStream out = response.getOutputStream(); F.ServletOutputStream out = response.getServletOutputStream("image/gif"); 19. Which of the given statements are correct regarding the following JSP page code?

Assume that the request for this page contains a parameter mystring=hello. Select 1 correct option. A.It will print "" B.It will print "hello" C.It will not compile D.It will throw exception at runtime 20. Select the correct sequence of actions that a servlet container performs before servicing any request.

A.Instantiate listeners defined in the deployment descriptor B.Initialize filters defined in the deployment descriptor C.Initialize servlets that are set to load on startup D.Call the contextInitialized method on the listeners implementing ServletContextListener interface

21.Which of the following is a valid life cycle event listener interface but is NOT configured in the web.xml?

Select 1 correct option. A.HttpSessionListener B.SessionActivationListener C.HttpSessionBindingListener D.ContextAttributeListener E.SessionAttributeListener 22. How can you retrieve the data sent by the FORM displayed by following HTML page code?

Select 2 correct options. A.request.getParameter("name"); B.request.getAttribute("name"); C.request.getInputStream(); D.request.getReader(); E.request.getFileInputStream();

OCEJWCD 6 Mock Questions - 1 (Answers) 1)C 2)A,B 3)A 4)description or 5)A,C,D 6)B 7)D 8) i. session is activated or passivated -C ii. session is timed out -A,B iii. an attribute is replaced in the session - D iv. a session is created - A 9)C,D,E 10)C 11)A,B 12)A,C,E,F 13) comment -E directive - D declaration -F scriptlet -C custom tag -A expression - B 14)D 15)A 16)A

17)B,C 18)D 19)A 20)A,D,B,C 21)C 22)C,D

OCEJWCD 6 Mock Questions - 2 1.you are using a tag library with prefix "generator", which supports a tag named "random". This tag generates a random number and sets it to a variable named "value". Which of the following will output this value in the page?

Select 1 correct option. A.value B. C. D. E.None of the above 2. Which of the following pairs of HTTP method and HttpServlet class method are a valid combination for a request and the request handler method?

Select 2 correct options. A.GET - service() B.POST - doPost() C.GET - doPost() D.GET - doGet() E.POST - service() 3.You want to get notified whenever there is a change in the attribute list of the ServletContext of your web application. Which listener interface would you implement?

Select 1 correct option A.ServletListener B.ServletContextListener C.ServletContextAttributeListener D.HttpServletContextListener E.HttpServletListener 4.A JSP page myerror.jsp has been invoked as a result of an exception from another JSP page. How can you access the Throwable object that refers to the exception in myerror.jsp?

Select 1 correct option. A.Using the implicit variable error B.Using the implicit variable request.error C.Using the implicit variable exception D.Using the implicit variable throwable E.None of these because the class of the implicit variable is not java.lang.Throwable 5.Which of the following are valid return values for doStartTag() method?

Select 3 correct options. A.BodyTag.SKIP_BODY B.Tag.SKIP C.Tag.EVAL_BODY_INCLUDE D.Tag.EVAL_BODY_AGAIN E.BodyTag.EVAL_BODY_BUFFERED 6.Which of the following statements are correct for a custom tag that can take any number of arbitrary attributes?

Select 2 correct options. A.The body-content element for the tag in the TLD file must have a value of JSP. B.The tag handler must implement the method setAttribute(String key, String value). C.The tag element in the TLD file for the tag must have true. D.The class implementing the tag must implement javax.servlet.jsp.tagext.DynamicAttributes interface.

E.Dynamic attributes cannot have request time expression values F.A JSP page sets a dynamic attribute using action 7.Assuming that occurs before the use of the custom tags of the tag library named utils, identify the possibly valid empty custom tag declarations. (Assume that transpose is a valid tag in the given tag library.)

Select 2 correct options. A. B. C.200 D. E.None of the above is correct as every tag has to have a body 8.Which of the following defines the class name of a tag in a TLD?

Select 1 correct option. A.tag-class-name B.tag-class C.class-name D.class 9.What should be the value of subelement of element in a TLD file if the tag should not have any contents as its body?

Select 1 correct option. A.blank B.empty C.null D.false E.The subelement itself should be absent 10.Which interface and method should be used to retrieve a servlet initialization parameter value?

Select 1 correct option. A.ServletConfig : getParameter(String name) B.ServletConfig : getInitParameter(String name) C.ServletContext : getInitParameter(String name)) D.ServletConfig : getInitParameters(String name) E.ServletConfig : getInitParameterNames(String name) 11. You need to put a com.enthu.User bean referred by 'userBean' variable in request scope with an ID of "user" from within a servlet. Which of the following statements accomplishes this task?

Select 1 correct option. A.request.put("user", userBean); B.request.add(userBean, "user"); C.request.putAttribute("user", userBean); D.request.setAttribute("user", userBean); E.request.setParameter(userBean, "user"); F.request.put(userBean, "user"); 12.Consider the following code:

public class MyTagHandler extends TagSupport { public int doStartTag() throws JspException { try { //insert code here }

catch(Exception e){ } return super.doStartTag(); } } Which of the following options, when inserted in the above code causes the value "hello" to be output? Select 1 correct option. A.JspWriter out = pageContext.getOut(); out.print("hello"); B.JspWriter out = pageContext.getWriter(); out.print("hello"); C.JspWriter out = getPageContext().getWriter(); out.print("hello"); D.JspWriter out = new JspWriter(pageContext.getWriter()); out.print("hello"); E.JspWriter out = getPageContext().getOut(); out.print("hello"); 13.Which of the following is a correct JSP declaration for a variable of class java.util.Date?

Select 1 correct option. A. B. C. D. 14.Which method can be invoked on a session object so that it is never invalidated by the servlet container automatically?

Select 1 correct option. A.setTimeOut(-1) B.setTimeOut(Integer.MAX_INT) C.setTimeOut(0) D.setMaxInactiveInterval(-1) E.setMaxInactiveInterval(Integer.MAX_INT) 15.Which of the following elements are mandatory under the element of a deployment descriptor?

Select 1 correct option. A. B. C. D. E.None of these. 16.Which of the following implicit variables should be used by a jsp page to access a page initialization parameter?

Select 1 correct option. A.pageContext B.application C.config D.context E.page 17.You are given a tag library that has:

1. A tag named getMenu that takes an attribute 'subject' which can be a dynamic value. 2. A tag named getHeading that takes an attribute 'report'. Which of the following are correct uses of this library? Select 3 correct options. A. B. C.

D. E. 18.You are working with a tag library which is packaged in a jar file named htmlutil.jar. This jar file also contains a META-INF/htmlutil.tld file which has a uri element as follows: http://www.xyzcorp.com/htmlLib What can you do to access this library from your JSP pages

Select 1 correct option. A.You must define the element in the web.xml to specify the mapping for to the location of this jar file. B.There is no need for the element in the web.xml, however, you need the taglib directive in the JSP pages. C.You can directly access the tags of this library from the JSP pages without any taglib directive. D.You do not need the taglib directive, but you do need to specify the element in the web.xml. E.None of these. 19.Which of the following are valid iteration mechanisms in jsp?

1.
View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF