JavaBeat
Search JavaBeat

Certification Kits
SCJP 1.5 Exam Questions
SCJP 1.6 Exam Questions
SCWCD 1.4 Exam Questions
SCWCD 5.0 Exam Questions
SCBCD 5.0 Exam Questions
SCWCD 1.4 Links
SCWCD 1.4 Home
SCWCD Books
Newbie
Objectives
Tutorials
Mock Exams
300 Mock Exams
SCWCD Mock - 1
SCWCD Mock - 2
SCWCD Mock - 3
SCWCD Mock - 4
SCWCD Mock - 5
SCWCD Mock - 6
SCWCD Mock - 7
Forums
Certification Links
SCJP 1.4
SCJP 1.5
SCJP 1.6
SCWCD 1.4
SCWCD 5.0
SCBCD 5.0
SCEA
SCEA 5.0
JavaBeat
Home
Articles
Tips
Code
QnA
Forums
300 Mock Questions on SCWCD 1.4 - JUST Rs.250 or 10 USD
Send us mail to sales@javabeat.net
more details
Do you have paypal account? Click Here to pay now and get the questions.

SCWCD 1.4 Mock Questions - 6

1.Which constant is used to notify the container to reevaluate the custom tag's body?

Please select one correct answer.
A. EVAL_BODY
B. EVAL_BODY_TAG
C. EVAL_BODY_AGAIN
D. EVAL_BODY_INCLUDE

2. Which of the following statements regarding the JSP action tag are TRUE?

Please select three correct answers.
A. Provides translation-time instructions to the JSP engine.
B. Can be used to declare a JavaBean instance in a JSP page
C. Can be used to generate HTML code to embed an applet on a web page
D. User-defined actions can be created
E. language is a standard JSP action.

3.Which of the following methods can be used to pass request to another servlet to handle by using the RequestDispatcher?

Please select two correct answers.
A. request(ServletRequest req, ServletResponse res)
B. include(ServletRequest req, ServletResponse res)
C. dispatch(ServletRequest req, ServletResponse res)
D. forward(ServletRequest req, ServletResponse res)
E. process(ServletRequest req, ServletResponse res)

4. Given the following code snippet, what would be the output you can expect to see on the web page?

Please select one correct answer.

import javax.servlet.*;
    import javax.servlet.http.*;

    public class MyServlet extends GenericServlet {

        public void init() {                      //1
            // Do something
        }

        public void init(ServletConfig config)    //2
        throws ServletException{ 
            // Do something
            super.init(config);                   //3
        }

        public void destroy() {                   //4
            // Do something
        }

        public void service(ServletRequest req,   //5
        ServletResponse res) {
            // Do something
        }    
    }

A. Method //1 is necessary for this code to compile
B. Method //2 is necessary for this code to compile
C. Line //3 is necessary for this code to run
D. Method //4 is necessary for this code to compile
E. Method //5 is necessary for this code to compile

5. Which pattern is normally used to encapsulate database SQL statement?

Please select one correct answer.
A. Value Object
B. Data Value Object
C. Data Access Object
D. Business Object
E. Business Delegate

6.For special character used in request URI, which of the following statements are correct?

Please select two correct answers.
A. The ampersand (&) is used to separate name/value pairs.
B. The plus sign (+) is used to fill blank space
C. The dash sign (-) is used to separate the name and value.
D. The percent sign (%) is used to start a query string.

7.Which statements are TRUE regarding the HttpServlet method doPost(HttpServletRequest req, HttpServletResponse res)?

Please select two correct answers. A.The method is called by the server (via the service method) to allow a servlet to handle a POST or PUT request
B.The method is called by the server (via the service method) to allow a servlet to handle a POST or GET request.
C.The method is called by the server (via the service method) to allow a servlet to handle a POST request
D.The method is called by the server (via the service method) to allow a servlet to handle a GET request
E.The method allows the client to send data of unlimited length to the Web server a single time.
F. Operations requested through this method will NEVER have side effects.

8.Which of the following design pattern is used to reduce the amount of network traffic when transferring data?

Please select one correct answer
A. Model View Controller
B. Data Access Object
C. Business Delegate
D. Value Object

9.What is the authentication type which uses digital certificates as a security mechanism for a web based application?

10.Which of the following method is used to retrieve the value associated to the init parameter defined in the init-param tag?

Please select one correct answer.
A. getParameter(String name)
B. getInitParameter(String name)
C. getParameters()
D. getInitParameterValue(String name)

11. Which of the following statements are TRUE for the code given below?

Please select three correct answers.

    int MAX_AGE;
    Cookie cookie = new Cookie("user", user);
    cookie.setMaxAge(MAX_AGE);
    response.addCookie(cookie);
A. If MAX_AGE = 10 the cookie will expire after 10 seconds.
B. If MAX_AGE = 10 the cookie will expire after 600 seconds.
C. If MAX_AGE = 0 the cookie will be deleted.
D. If MAX_AGE = -1 the cookie is not stored persistently
E. If MAX_AGE = -1; the code will generate run-time error.

12. In which directory you will most likely find the file myBaseUtil.jar?

Please select two correct answers.
A. example/WEB-INF
B. example/lib
C. example/WEB-INF/lib
D. example/WEB-INF/classes
E. example/META-INF/lib

13.Which of the following requirements are needed for FORM based authentication in a web based application?

Please select four correct answers.
A. The session attribuite j_sessionid must be set.
B. The action or url must be j_security_check.
C. The name attribute for the username must be j_username
D. The form method must be POST.
E. The name attribute for the password must be j_password.
F. Client side cookie must be enabled.

14.Which of the following deployment descriptor snippet will map the following request URI: /tech/hello/index.jsp for web application with context path as "tech"?

Please select one correct answer.

A. <servlet-mapping>
  <servlet-name>HelloWorldServlet</servlet-name>
  <url-pattern>/hello/*</url-pattern>
</servlet-mapping>
B. <servlet-mapping>
  <servlet-name>HelloWorldServlet</servlet-name>
  <url-pattern>/hello/*.jsp</url-pattern>
</servlet-mapping>
C. <servlet-mapping>
  <servlet-name>HelloWorldServlet</servlet-name>
  <url-pattern>/hello/index.jsp</url-pattern>
</servlet-mapping>
D. <servlet-mapping>
  <servlet-name>HelloWorldServlet</servlet-name>
  <url-pattern>hello/*</url-pattern>
</servlet-mapping>

15. Which of the following methods will enable you to get one or more values from a request object?

Please select two correct answers.
A. getParameter(String name)
B. getParameters(String name)
C. getAllParameters()
D. getParameterValues(String name)
E. getAllAttributes()

16. Is the following statement TRUE or FALSE?

Please select one correct answer.
The four methods for session management in the context of web-based application are: Cookie, HttpSession object, URL rewriting and Hidden value.
A.True
B.False

17. Which of the following packages are implicitly imported in the JSP page?

Please select three correct answers.
A. java.lang.*
B. java.util.*
C. javax.servlet.*
D. javax.servlet.jsp.*
E. javax.servlet.jsp.tagext.*

18.Which of the following is NOT an authentication method used by a web container?

Please select one correct answer.
A. BASIC
B. DIGEST
C. SSL
D. FORM

19. Which methods can be used for writing logging message to servlet log file?

Please select two correct answers.
A. log(String msg)
B. log(int code, String msg)
C. log(String msg, Throwable t)
D. log(int code, String msg, Throwable t)

20.Which tag is used in web.xml to mark a web application to be suitable for running between multiple systems.

Please select one correct answer.
A. multiple
B. distributable
C. resource-ref
D. transferrable
E. splitable

21. Which of the following are VALID servlet error attributes?

Please select three correct answers.
A. javax.servet.error.status_code
B. javax.servet.error.exception
C. javax.servet.error.uri
D. javax.servet.error.message
E. javax.servet.error.query

22. Which statement is TRUE about the following jsp code snippet?

Please select one correct answer.

<%
    String theKey = "key";     
    String theValue = "value";     
    session.removeAttribute(theKey);         //1  
%>      

    session.setAttribute("<%= theKey %>",
                         "<%= theValue %>"); //2
	
    session.getAttribute("<%= theKey %>");   //3   

<%= session.getAttribute(theKey) %>          //4

A. The code compiles but might have runtime NullPointerException at //1
B. There will have compilation error at //2 and //3.
C. There will have output as null at //4.
D. There will have output as theValue at //4

23. Which of the following are VALID taglib configuration?

Please select three correct answers.

A.

<taglib>
        ...
        <tag>
            <name>myTag</name>
            <tag-class>MyTag</tag-class>
        </tag>
        ...
    </taglib>
B.
<taglib>
        ...
        <tag>
            <name>myTag</name>
            <tag-class>MyTag</tag-class>
            <body-content>SERVLET</body-content>
        </tag>
        ...
    </taglib>
C.
<taglib>
        ...
        <tag>
            <name>myTag</name>
            <tag-class>MyTag</tag-class>
            <attribute>
                <name>name</name>
            </attribute>
        </tag>
        ...
    </taglib>
D.
taglib>
        ...
        <tag>
            <name>myTag</name>
            <tei-class>MyTagInfo</tei-class>
            <body-content>JSP</body-content>
        </tag>
        ...
    </taglib>
E.
<taglib>
        ...
        <tag>
            <name>myTag</name>
            <tag-class>MyTag</tag-class>
            <tei-class>MyTagInfo</tei-class>
            <body-content>JSP</body-content>
            <attribute>
                <name>name</name>
                <required>true</required>
                <rtexprvalue>true</rtexprvalue>
                <type>java.lang.String</type>
            </attribute>
        </tag>
        ...
    </taglib>

24.Which of the following statement is FALSE regarding JSP page directive attributes default value?

Please select one correct answer..
A. The session attribute has default value as true
B. The buffer attribute has default value as 8kb
C. The autoflush attribute has default value as false
D. The isThreadSafe attribute has default value as true
E. The isErrorPage attribute has default value as false
F. The pageEncoding attribute has default value as ISO-8859-1

25.Which of the following deployment descriptor tags are used for context level parameter initialization?

Please select three correct answers.
A. param-name
B. context-name
C. context-param
D. param-value
E. context-value
F. context-attrib

26. Given the following code snippet, what would be the output you can expect to see on the web page?

Please select one correct answer.

// Calling servlet:

    public void doGet(HttpServletRequest req, 
    HttpServletResponse res) throws ServletException, IOException 
    {
        res.setContentType("text/html");
        PrintWriter out = res.getWriter();
        out.println("<HTML><BODY>");
        out.println("I am calling others!");
        RequestDispatcher rd= req.getRequestDispatcher("/MyServlet");
        rd.include(req, res);
        out.println("</BODY></HTML>");
        out.close();
    }

    // Target servlet:

    protected void doGet(HttpServletRequest req,
    HttpServletResponse res) throws ServletException, IOException 
    {
        PrintWriter out = res.getWriter();
        out.println("I am called by others!");
A."I am calling others!"
B."I am called by others!"
C.Both "I am calling others!" and "I am called by others!"
D.An IllegalStateException is thrown
E.An IOException is thrown

27.Which statement is NOT true about the SingleThreadModel interface?

Please select one correct answer
A.By implementing this interface it ensures that servlets handle only one
B.If a servlet implements this interface, no two threads will execute concurrently in the servlet's service method
C.This interface has no methods
D.The servlet container will ensure there will be only one instance of the servlet at a time if the servlet implements this interface
E.Class variables are not protected by this interface, but instance variables are protected.

28.Which of the following method is called upon the initialization of a servlet context?

Please select one correct answer
A. contextInitializing(ServletContextEvent e)
B. contextInitial(ServletContext e)
C. contextInitialize(ServletContext e)
D. contextInitialize(ServletContextEvent e)
E. contextInitialized(ServletContextEvent e)

29. Which of the following statements are TRUE?

Please select three correct answers
A.XML equivalent for JSP expression <%= expression %> is <jsp:expression>expression</jsp:expression>
B.XML equivalent for JSP scriptlet <% scriptlet %> is <jsp:scriptlet>scriptlet</jsp:scriptlet>
C.XML equivalent for JSP declaration <%! declaration %> is <jsp:declaration>declaration</jsp:declaration>.
D. XML equivalent for JSP include directive <%@ include file="url" %> is <jsp:include file="url"/>, where url must be relative
E. XML equivalent for JSP page directive <%@ page buffer="16kb" %> is <jsp:page buffer="16kb"/>

30. Please select CORRECT JSP useBean declaration methods

Please select three correct answers
A.<jsp:useBean id="user" beanName="TestUser" type="com.test.model.User" />
B.<jsp:useBean id="user" beanName="TestUser" class="com.test.model.User" />
C. <jsp:useBean beanName="TestUser" class="com.test.model.User" />
D. <jsp:useBean beanName="TestUser" class="com.test.model.User" />
E. <jsp:useBean id="user" type="com.test.model.User" />

31. Which statement is TRUE regarding the following code?

Please select one correct answer.

import javax.servlet.*;
    import javax.servlet.http.*;

    public class MyHttpServlet extends HttpServlet 
    implements SingleThreadModel {

        StringBuffer bufferOne = new StringBuffer();            //1

        static StringBuffer bufferTwo = new StringBuffer();     //2

        protected void doGet(HttpServletRequest req,            //3
        HttpServletResponse res) throws java.io.IOException{  

            HttpSession session = req.getSession();             //4 

            res.setContentType("text/html");
            java.io.PrintWriter out = res.getWriter();
            out.println("<html>");
            out.println("<head>");
            out.println("<title>This is my servlet!</title>");
            out.println("</head>");
            out.println("<body>");
            out.println("</body>");
            out.println("</html>");
            out.close();
        }
		
A.Variable bufferOne at //1 is NOT thread-safe.
B.Variable bufferTwo at //2 is NOT thread-safe
C.Both A and B
D.Variable req at //3 is NOT thread-safe
E.Variable session at //4 is NOT thread-safe
F.Both D and E

32.Select sample web application file listing with appropriate directory structure

Please select two correct answers.

A.
index.html
/login.jsp
/images/logo.gif
/WEB-INF/web.xml
/WEB-INF/lib/basic.jar
/WEB-INF/classes/Test.class
B.
/index.html
/login.jsp
/images/logo.gif
/WEB-INF/web.xml
/WEB-INF/jar/basic.jar
/WEB-INF/classes/Test.class
C.
/index.html
/login.jsp
/images/logo.gif
/WEB-INF/web.xml
/WEB-INF/classes/basic.jar
/WEB-INF/classes/Test.class
D.
/index.html
/login.jsp
/images/logo.gif
/META-INF/web.xml
/WEB-INF/jar/basic.jar
/WEB-INF/classes/Test.class
E.
/index.html
/login.jsp
/images/logo.gif
/META-INF/web.xml
/WEB-INF/lib/basic.jar
/WEB-INF/classes/Test.class
F.
index.html
/images/logo.gif
/WEB-INF/web.xml
/WEB-INF/jsp/login.jsp
/WEB-INF/lib/basic.jar
/WEB-INF/classes/Test.class

33. Which of the following data element will definitely be thread-safe?

Please select one correct answer
A. Local variables
B. Instance variables
C. Static variables
D. Class variables
E. Context attributes

34. Select the correct order that JSP methods are invoked by servlet container

Please select one correct answer.
A. jspInit(), jspService(), jspDestroy()
B. jspInit(), _jspService(), jspDestroy()
C. _jspInit(), jspService(), _jspDestroy()
D. _jspInit(), _jspService(), _jspDestroy()

35. Which of the following element is not included in a URL?

Please select one correct answer
A. Client ip
B.Protocol
C.Server Name
D.Query string
E.Port name

36. Which of the following listeners is notified when a session is initialized?

Please select one correct answer.
A. HttpSessionBindingListener
B. SessionBindingListener
C. HttpSessionListener
D. HttpSessionListener
E. HttpSessionChangedListener

37. Which of the following best describes the life cycle of a JSP?

Please select one correct answer.

A.
JSP page is translated into a servlet code
Servlet code is compiled
Servlet is loaded into memory
Servlet instance is created
B.
JSP page is translated into a servlet code
Servlet is loaded into memory
Servlet code is compiled
Servlet instance is created
C.
JSP is compiled
JSP is translated into a servlet code
Servlet is loaded into memory
Servlet instance is created
D.
JSP is loaded into memory
Servlet code is compiled
Servlet instance is created
Servlet is loaded into memory
E.
JSP page is translated into a servlet code
Servlet code is compiled
Servlet instance is created
Servlet is loaded into memory

38. Please identify the three methods declared in javax.servlet.Filter

Please select three correct answers.
A.service
B.init
C.destroy
D.filter
E.doFilter

39.Which of the following deployment descriptor segments are VALID for security-related configuration of a web application?

Please select two correct answers.

A.

<login-config>
    <auth-method>FORM</auth-method>
    <login-config>
        <form-login-page>/login.jsp</form-login-page>
        <form-error-page>/error.jsp</form-error-page>
    </login-config>
</login-config>
B.
<security-role>
    <description>My description.</description>
    <role-name>Manager</role-name>
</security-role>
C.
<security-constraint>
    <web-resource-collection>
        <web-resource-name>SecureStuff</web-resource-name>
        <url-mapping>/servlet/secure</url-mapping>
        <http-method>POST</http-method>
    </web-resource-collection>
</security-constraint>
D.
<security-constraint>
    <auth-constraint>
        <role-name>Broker</role-name>
    </auth-constraint>
</security-constraint>
E.
<security-constraint>
    <web-resource-collection>
        <web-resource-name>SecureStuff</web-resource-name>
    </web-resource-collection>
    <auth-constraint>
        <role-name>Broker</role-name>
    </auth-constraint>
</security-constraint>

40.Based on the following information, please construct the full path for the servlet.

Please select one correct answer

docbase = c:/temp/
    context path = /test 
    alias name = MyMail
    servlet-name = com.jiris.common.util.MailServlet
    url-pattern = /mail/*
A.c:/temp/mail/com/jiris/common/util/MailServlet.class
B.c:/temp/test/com/jiris/common/util/MailServlet.class
C.c:/temp/mail/test/com/jiris/common/util/MailServlet.class
D.c:/temp/test/mail/com/jiris/common/util/MailServlet.class

41.The ServletContext object are accessible from which of the following objects?

Please select three correct answers.
A.HttpServlet
B.GenericServlet
C.HttpSession
D.ServletConfig
E.ServletResponse

42.Which of the following method is used to store object into a request object?

Please select one correct answer
A. addAttribute(String name, String obj)
B. putAttribute(String name, Object obj)
C. setAttribute(String name, String obj)
D. setAttribute(String name, Object obj)
E. addObject(String name, Object obj)

43. Which request method will be invoked for the following code?

Please select one correct answer.
,code>
<html>
        <body>
            <form action=´/servlet/comment´>
                <p>Please provide your comment here:</p>
                <input type=´text´ size=´40´ name=´Comment´>
                <input type=´submit´ value=´Submit´>
            </form>
        </body>
<html>
A.GET
B.POST
C.HEAD
D.TRACE
E.PUT

44.Which of the following method might be invoked more than one time?

Please select one correct answer
A.doStartTag()
B.doInitBody()
C.doAfterBody()
D.doEndTag()

45.Which of the following methods are used to send an error page to the client?

Please select two correct answers
A.log(String msg)
B.log(String msg, Throwable t)
C.sendError(int code)
D.sendError(int code, String msg)
E.sendError(int code, String msg, Throwable t)

46.Which of the following requests should be performed by using a POST method?

Please select two corretion.
A.Inserting a record into a database
B.Accessing a static page
C.Retrieving an image
D.Sending credit card number
E.Searching record in a database

47.Which of the following are CORRECT ways to define inactive period of 5 minutes of a session before the server invalidates it?

Please select two correct answers
A.<session-timeout>5</session-timeout>
B.<session-timeout>300</session-timeout>
C.session.setMaxInactiveInterval(5);
D.session.setMaxInactiveInterval(300);
E.session.invalidate(5);

48.Which are the two mandatory attributes for JSP taglib directive?

Please select two correct answers.
A.uri
B.id
C.name
D.prefix
E.value
F.location

49.A session can be invalidated by which of the following:

Please select three correct answers
A.After a default period of inactivity, say 30 minutes
B.Client side user closes the browser
C.After a specified period of inactivity, say 10 minutes
D.Client side user machine crashes
E.Explicitly invalidate a session through method calls

50.What is the method declaration for the method used in the HttpServlet class that handles the HTTP GET request?

Please select one correct answer
A.doGet(ServletRequest req, ServletResponse res)
B.getPage(ServletRequest req, ServletResponse res)
C.doGet(HttpServletRequest req, HttpServletResponse res)
D.service(HttpServletRequest req, HttpServletResponse res)

SCWCD Mock Questions 6 - Answers


Sponsors
Webmaster Hosting Forum
Java Jobs
Latest in DLinks
http://javawave.blogspot.com/2008/04/quartz-job-scheduler-part-ii-example.html
Quartz Job Scheduler -- Part 1 (Setting up development project in Netbeans 6.1 beta)
Flex Messaging with BEA Workshop Studio
SOA and Virtualization: How do They Fit Together?
Introduction to Enterprise Portals - Why they Benefit IT and the Business
BEA WebLogic Operations Control: Application Virtualization for Enterprise Java
Best Practices for Building Production Quality EAR Files
BEA's SOA Reference Architecture - A Foundation for Business Agility
Blueprint for Successful SOA Integration
Guardian - What a tool!

JavaBeat Media (2004-2008), India
javabeat home | About Us
our network : opensource softwares
Copyright © 2007 JavaBeat