Free SCWCD Mock Exam for JSPs


This practice exam focuses on Java Server Pages.

Java Server Pages is the technology that changed the world of Web Applications. Developed on the robustness of Servlets, JSPs are the key component of the modern Web frameworks and the basis of promising new technologies like JSF.

This free practice material consists of 71 originally created questions. For those using Head First Servlets and JSP, 2nd Edition it’s a perfect companion for chapters 7-8.

  1. Put in the correct order the following events from a JSP’s lifecycle.
    1. create instance
    2. translation
    3. load class
    4. call jspInit()
    5. call jspDestroy()
    6. compilation
    7. call _jspService()

  2. How is a scriplet defined? (1 correct answer)
    1. <% %>
    2. <%@ %>
    3. <%= %>
    4. <%! %>

  3. How is a directive defined? (1 correct answer)
    1. <% %>
    2. <%@ %>
    3. <%= %>
    4. <%! %>

  4. How is an expression defined? (1 correct answer)
    1. <% %>
    2. <%@ %>
    3. <%= %>
    4. <%! %>

  5. How is a declaration defined? (1 correct answer)
    1. <% %>
    2. <%@ %>
    3. <%= %>
    4. <%! %>

  6. Which of the following is syntactically valid? (1 correct answer)
    1. <%@ page import=”java.util.List” %>
    2. <%@ page “import=java.util.List” %>
    3. <%@ page “import java.util.List” %>

  7. Which of the following is syntactically valid? (1 correct answer)
    1. <%@ page import=”java.util.*” %>
    2. <%@ page “import=java.util.*” %>
    3. <%@ page “import java.util.*” %>

  8. Which of the following are syntactically valid? (2 correct answers)
    1. <%@ page import=”java.util.List : java.util.ArrayList” %>
    2. <%@ page import=”java.util.List , java.util.ArrayList” %>
    3. <%@ page import=”java.util.List” import=”java.util.ArrayList” %>

  9. The following are all attributes of the page directive. (1 correct answer)
          ⇒ import
          ⇒ errorPage
          ⇒ contentType
          ⇒ isErrorPage
          ⇒ isELignored
          ⇒ isThreadSafe

    1. true
    2. false

  10. The following are all implicit objects of a JSP. (1 correct answer)

        ⇒ out

        ⇒ config

        ⇒ session

        ⇒ request

        ⇒ response

        ⇒ application

        ⇒ exception
        ⇒ pageContext
        ⇒ page

    1. true
    2. false

  11. What is the output of the following code? (1 correct answer)
    <%= session == pageContext.getSession() %>
    
    1. true
    2. false

  12. What is the output of the following code? (1 correct answer)
    <%= request == pageContext.getRequest() %>
    
    1. true
    2. false

  13. What is the output of the following code? (1 correct answer)
    <%= response == pageContext.getResponse() %>
    
    1. true
    2. false

  14. What is the output of the following code? (1 correct answer)
    <%= config == pageContext.getServletConfig() %>
    
    1. true
    2. false

  15. What is the output of the following code? (1 correct answer)
    <%= application == session.getServletContext() %>
    
    1. true
    2. false

  16. What is the output of the following code? (1 correct answer)
    <%= application == pageContext.getServletContext() %>
    
    1. true
    2. false

  17. What is the output of the following code? (1 correct answer)
    <%= application == request.getSession().getServletContext() %>
    
    1. true
    2. false

  18. What is the output of the following code? (1 correct answer)
    <%= page instanceof JspPage %>
    
    1. true
    2. false

  19. What is the output of the following code? (1 correct answer)
    <%= out instanceof JspWriter %>
    
    1. true
    2. false

  20. What is the output of the following code? (1 correct answer)
    <% session.setAttribute("name", "Diogenes"); %>
    <%= session.getAttribute("name") %>
    
    1. Diogenes
    2. null

  21. What is the output of the following code? (1 correct answer)
    <% session.setAttribute("name", "Diogenes"); %>
    <%= session.getAttribute("Diogenes") %>
    
    1. Diogenes
    2. null

  22. What is the output of the following code? (1 correct answer)
    <% session.setAttribute("name", "Diogenes"); %>
    <%= pageContext.getAttribute("name") %>
    
    1. Diogenes
    2. null

  23. What is the output of the following code? (1 correct answer)
    <% session.setAttribute("name", "Diogenes"); %>
    <%= pageContext.getAttribute("name", 
                                 pageContext.APPLICATION_SCOPE) %>
    
    1. Diogenes
    2. null

  24. What is the output of the following code? (1 correct answer)
    <% session.setAttribute("name", "Diogenes"); %>
    <%= pageContext.getAttribute("name", 
                                 pageContext.SESSION_SCOPE) %>
    
    1. Diogenes
    2. null

  25. What is the output of the following code? (1 correct answer)
    <% session.setAttribute("name", "Diogenes"); %>
    <%= pageContext.findAttribute("name") %>
    
    1. Diogenes
    2. null

  26. What is the output of the following code? (1 correct answer)
    <% session.setAttribute("name", "Diogenes"); %>
    <%= pageContext.SESSION_SCOPE == 
        pageContext.getAttributesScope("name") %>
    
    1. true
    2. false

  27. Consider this code.
    <%-- input.jsp --%>
    <html>
      <body>
        <form action="output.jsp">
          <input type="text" name="yourname" value="Bond"/>
          <input type="submit" value="OK" />
        </form>
      </body>
    </html>
    
    <%-- output.jsp --%>
    <html>
      <body>
        Hello <%= request.getAttribute("yourname")%> !!
      </body>
    </html>
    

    What is the output when the form is submitted? (1 correct answer)

    1. “Hello null !!”
    2. “Hello Bond !!”

  28. Consider this code.
    <%-- input.jsp --%>
    <html>
      <body>
        <form action="output.jsp">
          <input type="text" name="yourname" value="Bond"/>
          <input type="submit" value="OK" />
        </form>
      </body>
    </html>
    
    <%-- output.jsp --%>
    <html>
      <body>
        Hello <%= request.getParameter("yourname")%> !!
      </body>
    </html>
    

    What is the output when the form is submitted? (1 correct answer)

    1. “Hello null !!”
    2. “Hello Bond !!”

  29. Consider this code.
    <%-- input.jsp --%>
    <html>
      <body>
        <form action="output.jsp">
          <input type="text" name="yourname" value="Bond"/>
          <input type="submit" value="OK" />
        </form>
      </body>
    </html>
    
    <%-- output.jsp --%>
    <html>
      <body>
        Hello <%= request.getParameter("OK")%> !!
      </body>
    </html>
    

    What is the output when the form is submitted? (1 correct answer)

    1. “Hello null !!”
    2. “Hello submit !!”

  30. Consider this code.
    <%-- input.jsp --%>
    <html>
      <body>
        <form action="output.jsp">
          <input type="text" name="yourname" value="Bond"/>
          <input type="submit" name="submit" value="OK" />
        </form>
      </body>
    </html>
    
    <%-- output.jsp --%>
    <html>
      <body>
        Hello <%= request.getParameter("submit")%> !!
      </body>
    </html>
    

    What is the output when the form is submitted? (1 correct answer)

    1. “Hello null !!”
    2. “Hello OK !!”
    3. “Hello submit !!”

  31. Consider this code.
    package library;
    public class Book {
       private String title;
       public Book() {}
       // get and set methods
    }
    
    <%-- input.jsp --%>
    <html>
      <body>
        <form action="output.jsp">
          <input type="text" name="about" value="Mathematics"/>
          <input type="submit" value="OK" />
        </form>
      </body>
    </html>
    
    <%-- output.jsp --%>
    <jsp:useBean id="book" class="library.Book" scope="request" />
    <html>
      <body>
        I like <jsp:getProperty name="book" property="title" />!
      </body>
    </html>
    

    What is the output when the form is submitted? (1 correct answer)

    1. I like null!
    2. I like Mathematics!

  32. Consider this code.
    package library;
    public class Book {
       private String title;
       public Book() {}
       // get and set methods
    }
    
    <%-- input.jsp --%>
    <html>
      <body>
        <form action="output.jsp">
          <input type="text" name="about" value="Mathematics"/>
          <input type="submit" value="OK" />
        </form>
      </body>
    </html>
    
    <%-- output.jsp --%>
    <jsp:useBean id="book" class="library.Book" scope="request" />
    <jsp:setProperty name="book" property="title" param="title" />
    <html>
      <body>
        I like <jsp:getProperty name="book" property="title" />!
      </body>
    </html>
    

    What is the output when the form is submitted? (1 correct answer)

    1. I like null!
    2. I like Mathematics!

  33. Consider this code.
    package library;
    public class Book {
       private String title;
       public Book() {}
       // get and set methods
    }
    
    <%-- input.jsp --%>
    <html>
      <body>
        <form action="output.jsp">
          <input type="text" name="about" value="Mathematics"/>
          <input type="submit" value="OK" />
        </form>
      </body>
    </html>
    
    <%-- output.jsp --%>
    <jsp:useBean id="book" class="library.Book" scope="request" />
    <jsp:setProperty name="book" property="title" param="about" />
    <html>
      <body>
        I like <jsp:getProperty name="book" property="title" />!
      </body>
    </html>
    

    What is the output when the form is submitted? (1 correct answer)

    1. I like null!
    2. I like Mathematics!

  34. Consider this code.
    package library;
    public class Book {
       private String title;
       public Book() {}
       // get and set methods
    }
    
    <%-- input.jsp --%>
    <html>
      <body>
        <form action="output.jsp">
          <input type="text" name="about" value="Mathematics"/>
          <input type="submit" value="OK" />
        </form>
      </body>
    </html>
    
    <%-- output.jsp --%>
    <jsp:useBean id="book" class="library.Book" scope="request" />
    <jsp:setProperty name="book" property="title" value="Art" />
    <html>
      <body>
        I like <jsp:getProperty name="book" property="title" />!
      </body>
    </html>
    

    What is the output when the form is submitted? (1 correct answer)

    1. I like Art!
    2. I like Mathematics!

  35. Consider this code.
    package library;
    public class Book {
       private String title;
       public Book() {}
       // get and set methods
    }
    
    <%-- input.jsp --%>
    <html>
      <body>
        <form action="output.jsp">
          <input type="text" name="about" value="Mathematics"/>
          <input type="submit" value="OK" />
        </form>
      </body>
    </html>
    
    <%-- output.jsp --%>
    <jsp:useBean id="book" class="library.Book" scope="request" >
      <jsp:setProperty name="book" property="title" value="Art" />
    </jsp:useBean>
    <html>
      <body>
        I like <jsp:getProperty name="book" property="title" />!
      </body>
    </html>
    

    What is the output when the form is submitted? (1 correct answer)

    1. I like Art!
    2. I like Mathematics!

  36. Consider this code.
    package library;
    public class Book {
       private String title;
       public Book() {}
       // get and set methods
    }
    
    <%-- input.jsp --%>
    <html>
      <body>
        <form action="output.jsp">
          <input type="text" name="about" value="Mathematics"/>
          <input type="submit" value="OK" />
        </form>
      </body>
    </html>
    
    <%-- output.jsp --%>
    <jsp:useBean id="book" class="library.Book" scope="request" >
      <jsp:setProperty name="book" property="title" param="Mathematics" />
    </jsp:useBean>
    <html>
      <body>
        I like <jsp:getProperty name="book" property="title" />!
      </body>
    </html>
    

    What is the output when the form is submitted? (1 correct answer)

    1. I like null!
    2. I like Mathematics!

  37. Consider this code.
    package library;
    public class Book {
       private String title;
       public Book() {}
       // get and set methods
    }
    
    <%-- input.jsp --%>
    <html>
      <body>
        <form action="output.jsp">
          <input type="text" name="about" value="Mathematics"/>
          <input type="submit" value="OK" />
        </form>
      </body>
    </html>
    
    <%-- output.jsp --%>
    <jsp:useBean id="book" class="library.Book" scope="request" >
      <jsp:setProperty name="book" property="title" param="title" />
    </jsp:useBean>
    <html>
      <body>
        I like <jsp:getProperty name="book" property="title" />!
      </body>
    </html>
    

    What is the output when the form is submitted? (1 correct answer)

    1. I like null!
    2. I like Mathematics!

  38. Consider this code.
    package library;
    public class Book {
       private String title;
       public Book() {}
       // get and set methods
    }
    
    <%-- input.jsp --%>
    <html>
      <body>
        <form action="output.jsp">
          <input type="text" name="about" value="Mathematics"/>
          <input type="submit" value="OK" />
        </form>
      </body>
    </html>
    
    <%-- output.jsp --%>
    <jsp:useBean id="book" class="library.Book" scope="request" >
      <jsp:setProperty name="book" property="title" param="about" />
    </jsp:useBean>
    <html>
      <body>
        I like <jsp:getProperty name="book" property="title" />!
      </body>
    </html>
    

    What is the output when the form is submitted? (1 correct answer)

    1. I like null!
    2. I like Mathematics!

  39. Consider this code.
    package library;
    public class Book {
       private String title;
       public Book() {}
       // get and set methods
    }
    
    <%-- input.jsp --%>
    <html>
      <body>
        <form action="output.jsp">
          <input type="text" name="about" value="Mathematics"/>
          <input type="submit" value="OK" />
        </form>
      </body>
    </html>
    
    <%-- output.jsp --%>
    <jsp:useBean id="book" class="library.Book" scope="request" >
      <jsp:setProperty name="book" property="title" param="about" />
    </jsp:useBean>
    <jsp:setProperty name="book" property="title" value="Art" />
    <html>
      <body>
        I like <jsp:getProperty name="book" property="title" />!
      </body>
    </html>
    

    What is the output when the form is submitted? (1 correct answer)

    1. I like Art!
    2. I like Mathematics!

  40. Consider this code.
    package library;
    public class Book {
       private String title;
       public Book() {}
       // get and set methods
    }
    
    <%-- input.jsp --%>
    <html>
      <body>
        <form action="output.jsp">
          <input type="text" name="title" value="Mathematics"/>
          <input type="submit" value="OK" />
        </form>
      </body>
    </html>
    
    <%-- output.jsp --%>
    <jsp:useBean id="book" class="library.Book" scope="request" >
      <jsp:setProperty name="book" property="title" param="title" />
    </jsp:useBean>
    <html>
      <body>
        I like <jsp:getProperty name="book" property="title" />!
      </body>
    </html>
    

    What is the output when the form is submitted? (1 correct answer)

    1. I like null!
    2. I like Mathematics!

  41. Consider this code.
    package library;
    public class Book {
       private String title;
       public Book() {}
       // get and set methods
    }
    
    <%-- input.jsp --%>
    <html>
      <body>
        <form action="output.jsp">
          <input type="text" name="title" value="Mathematics"/>
          <input type="submit" value="OK" />
        </form>
      </body>
    </html>
    
    <%-- output.jsp --%>
    <jsp:useBean id="book" class="library.Book" scope="request" >
      <jsp:setProperty name="book" property="title" param="*" />
    </jsp:useBean>
    <html>
      <body>
        I like <jsp:getProperty name="book" property="title" />!
      </body>
    </html>
    

    What is the output when the form is submitted? (1 correct answer)

    1. I like null!
    2. I like Mathematics!

  42. Consider this code.
    package library;
    public class Book {
       private String title;
       public Book() {}
       // get and set methods
    }
    
    <%-- input.jsp --%>
    <html>
      <body>
        <form action="output.jsp">
          <input type="text" name="title" value="Mathematics"/>
          <input type="submit" value="OK" />
        </form>
      </body>
    </html>
    
    <%-- output.jsp --%>
    <jsp:useBean id="book" class="library.Book" scope="request" >
      <jsp:setProperty name="book" property="title" />
    </jsp:useBean>
    <html>
      <body>
        I like <jsp:getProperty name="book" property="title" />!
      </body>
    </html>
    

    What is the output when the form is submitted? (1 correct answer)

    1. I like null!
    2. I like Mathematics!

  43. Consider this code.
    package library;
    public class Book {
       private String title;
       public Book() {}
       // get and set methods
    }
    
    <%-- input.jsp --%>
    <html>
      <body>
        <form action="output.jsp">
          <input type="text" name="title" value="Mathematics"/>
          <input type="submit" value="OK" />
        </form>
      </body>
    </html>
    
    <%-- output.jsp --%>
    <jsp:useBean id="book" class="library.Book" scope="request" >
      <jsp:setProperty name="book" property="*" />
    </jsp:useBean>
    <html>
      <body>
        I like <jsp:getProperty name="book" property="title" />!
      </body>
    </html>
    

    What is the output when the form is submitted? (1 correct answer)

    1. I like null!
    2. I like Mathematics!

  44. Consider this code.
    package library;
    public class Book {
       private String title;
       public Book() {}
       // get and set methods
    }
    
    <%-- input.jsp --%>
    <html>
      <body>
        <form action="output.jsp">
          <input type="text" name="title" value="Mathematics"/>
          <input type="submit" value="OK" />
        </form>
      </body>
    </html>
    
    <%-- output.jsp --%>
    <jsp:useBean id="book" type="library.Book" scope="request" >
      <jsp:setProperty name="book" property="*" />
    </jsp:useBean>
    <html>
      <body>
        I like <jsp:getProperty name="book" property="title" />!
      </body>
    </html>
    

    What is the output when the form is submitted? (1 correct answer)

    1. I like Mathematics!
    2. An exception is thrown at runtime.

  45. Consider this code.
    package library;
    public class Book {
       private String title;
       public Book() {}
       // get and set methods
    }
    
    <%-- input.jsp --%>
    <html>
      <body>
        <form action="output.jsp">
          <input type="text" name="title" value="Mathematics"/>
          <input type="submit" value="OK" />
        </form>
      </body>
    </html>
    
    <%-- output.jsp --%>
    <jsp:useBean id="book" type="library.Book" class="library.Book" scope="request" >
      <jsp:setProperty name="book" property="*" />
    </jsp:useBean>
    <html>
      <body>
        I like <jsp:getProperty name="book" property="title" />!
      </body>
    </html>
    

    What is the output when the form is submitted? (1 correct answer)

    1. I like Mathematics!
    2. An exception is thrown at runtime.

  46. Consider this code.
    package library;
    public class Book {
       private String title;
       public Book() {}
       // get and set methods
    }
    
    <%-- input.jsp --%>
    <jsp:useBean id="book" class="library.Book" scope="request" >
      <jsp:setProperty name="book" property="title" value="Head First Servlets and JSP" />
    </jsp:useBean>
    <html>
      <body>
        <a href="output.jsp">click here</a>
      </body>
    </html>
    
    <%-- output.jsp --%>
    <jsp:useBean id="book" class="library.Book" scope="request" />
    <html>
      <body>
        I like <jsp:getProperty name="book" property="title" />!
      </body>
    </html>
    

    What is the output when the form is submitted? (1 correct answer)

    1. I like null!
    2. I like Head First Servlets and JSP!

  47. Consider this code.
    package library;
    public class Book {
       private String title;
       public Book() {}
       // get and set methods
    }
    
    <%-- input.jsp --%>
    <jsp:useBean id="book" class="library.Book" scope="session" >
      <jsp:setProperty name="book" property="title" value="Head First Servlets and JSP" />
    </jsp:useBean>
    <html>
      <body>
        <a href="output.jsp">click here</a>
      </body>
    </html>
    
    <%-- output.jsp --%>
    <jsp:useBean id="book" class="library.Book" scope="session" />
    <html>
      <body>
        I like <jsp:getProperty name="book" property="title" />!
      </body>
    </html>
    

    What is the output when the form is submitted? (1 correct answer)

    1. I like null!
    2. I like Head First Servlets and JSP!

  48. Consider this code.
    package library;
    public class Book {
       private String title;
       public Book() {}
       // get and set methods
    }
    
    <%-- input.jsp --%>
    <jsp:useBean id="book" class="library.Book" scope="session" >
      <jsp:setProperty name="book" property="title" value="Head First Servlets and JSP" />
    </jsp:useBean>
    <html>
      <body>
        <a href="output.jsp">click here</a>
      </body>
    </html>
    
    <%-- output.jsp --%>
    <jsp:useBean id="book" class="library.Book" scope="session" />
    <html>
      <body>
        I like <%= book.getTitle() %>!
      </body>
    </html>
    

    What is the output when the form is submitted? (1 correct answer)

    1. I like null!
    2. I like Head First Servlets and JSP!

  49. Consider this code and that there is no attribute in the request object.
    package value;
    public class Person {
       public String name;
    }
    
    <%-- hello.jsp --%>
    <html>
      <body>
        <jsp:useBean id="person" class="value.Person" scope="request">
          <jsp:setProperty name="person" property="name" value="Niko" />
        </jsp:useBean>
        Hello ${person.name}!!
      </body>
    </html>
    

    What is the output of hello.jsp? (1 correct answer)

    1. Hello !!
    2. Hello Niko!!
    3. An Exception is thrown at runtime

  50. Consider this code and that there is no attribute in the request object.
    package value;
    public class Person {
       private String name;
       public void setName(String name) {
          this.name = name;
       }
    }
    
    <%-- hello.jsp --%>
    <html>
      <body>
        <jsp:useBean id="person" class="value.Person" scope="request">
          <jsp:setProperty name="person" property="name" value="Niko" />
        </jsp:useBean>
        Hello ${person.name}!!
      </body>
    </html>
    

    What is the output of hello.jsp? (1 correct answer)

    1. Hello !!
    2. Hello Niko!!
    3. An Exception is thrown at runtime

  51. Consider this code and that there is no attribute in the request object.
    package value;
    public class Person {
       private String name;
       public String getName() {
          return name;
       }
    }
    
    <%-- hello.jsp --%>
    <html>
      <body>
        <jsp:useBean id="person" class="value.Person" scope="request">
          <jsp:setProperty name="person" property="name" value="Niko" />
        </jsp:useBean>
        Hello ${person.name}!!
      </body>
    </html>
    

    What is the output of hello.jsp? (1 correct answer)

    1. Hello !!
    2. Hello Niko!!
    3. An Exception is thrown at runtime

  52. Consider this code and that there is no attribute in the request object.
    package value;
    public class Person {
       private String name;
       public String getName() {
          return name;
       }
       public void setName(String name) {
          this.name = name;
       }
    }
    
    <%-- hello.jsp --%>
    <html>
      <body>
        <jsp:useBean id="person" class="value.Person" scope="request">
          <jsp:setProperty name="person" property="name" value="Niko" />
        </jsp:useBean>
        Hello ${person.name}!!
      </body>
    </html>
    

    What is the output of hello.jsp? (1 correct answer)

    1. Hello !!
    2. Hello Niko!!
    3. An Exception is thrown at runtime

  53. Consider this code and that there is no attribute in the request object.
    package value;
    public class Person {
       private String name;
       private Person() {
       }
       public String getName() {
          return name;
       }
       public void setName(String name) {
          this.name = name;
       }
    }
    
    <%-- hello.jsp --%>
    <html>
      <body>
        <jsp:useBean id="person" class="value.Person" scope="request">
          <jsp:setProperty name="person" property="name" value="Niko" />
        </jsp:useBean>
        Hello ${person.name}!!
      </body>
    </html>
    

    What is the output of hello.jsp? (1 correct answer)

    1. Hello !!
    2. Hello Niko!!
    3. An Exception is thrown at runtime

  54. Consider this code and that there is no attribute in the request object.
    package value;
    public class Person {
       private String onoma;
       public String getName() {
          return onoma;
       }
       public void setName(String name) {
          this.onoma = name;
       }
    }
    
    <%-- hello.jsp --%>
    <html>
      <body>
        <jsp:useBean id="person" class="value.Person" scope="request">
          <jsp:setProperty name="person" property="name" value="Niko" />
        </jsp:useBean>
        Hello ${person.name}!!
      </body>
    </html>
    

    What is the output of hello.jsp? (1 correct answer)

    1. Hello !!
    2. Hello Niko!!
    3. An Exception is thrown at runtime

  55. Consider this code and that there is no attribute in the request object.
    package value;
    public class Person {
       private String name;
       public String getName() {
          return name;
       }
       public void setName(String name) {
          this.name = name;
       }
    }
    
    <%-- hello.jsp --%>
    <html>
      <body>
        <jsp:useBean id="person" class="value.Person" scope="request">
          <jsp:setProperty name="person" property="name" value="Niko" />
        </jsp:useBean>
        Hello ${person.name[0]}!!
      </body>
    </html>
    

    What is the output of hello.jsp? (1 correct answer)

    1. Hello !!
    2. Hello Niko!!
    3. An Exception is thrown at runtime

  56. Consider this code and that there is no attribute in the request object.
    package value;
    public class Person {
       private String name;
       public String getName() {
          return name;
       }
       public void setName(String name) {
          this.name = name;
       }
    }
    
    <%-- hello.jsp --%>
    <html>
      <body>
        <jsp:useBean id="person" class="value.Person" scope="request">
          <jsp:setProperty name="person" property="name" value="Niko" />
        </jsp:useBean>
        Hello ${person.name["0"]}!!
      </body>
    </html>
    

    What is the output of hello.jsp? (1 correct answer)

    1. Hello !!
    2. Hello Niko!!
    3. An Exception is thrown at runtime

  57. Both HttpJspPage and JspPage are interfaces. (1 correct answer)
    1. true
    2. false

  58. HttpJspPage IS-A JspPage. (1 correct answer)
    1. true
    2. false

  59. HttpJspPage IS-A Servlet. (1 correct answer)
    1. true
    2. false

  60. What is the signature of method _jspService of HttpJspPage? (1 correct answer)
    1. void _jspService()
    2. void _jspService(HttpServletRequest, HttpServletResponse)
    3. void _jspService(HttpServletRequest, HttpServletResponse) throws IOException, ServletException

  61. The method _jspService of HttpJspPage should not be overriden by a JSP author. (1 correct answer)
    1. true
    2. false

  62. What is the signature of method jspInit of JspPage? (1 correct answer)
    1. void jspInit()
    2. void jspInit(HttpServletRequest, HttpServletResponse)
    3. void jspInit(HttpServletRequest, HttpServletResponse) throws IOException, ServletException

  63. What is the signature of method jspDestroy of JspPage? (1 correct answer)
    1. void jspDestroy()
    2. void jspDestroy(HttpServletRequest, HttpServletResponse)
    3. void jspDestroy(HttpServletRequest, HttpServletResponse) throws IOException, ServletException

  64. The methods jspInit and jspDestroy of JspPage may be overriden by a JSP author. (1 correct answer)
    1. true
    2. false

  65. Both PageContext and JspContext are abstract classes. (1 correct answer)
    1. true
    2. false

  66. PageContext IS-A JspContext. (1 correct answer)
    1. true
    2. false

  67. The following are all methods of JspContext. (1 correct answer)
          ⇒ findAttribute()
          ⇒ getAttribute()
          ⇒ setAttribute()
          ⇒ removeAttribute()
          ⇒ getAttributeNamesInScope()
          ⇒ getAttributesScope()
          ⇒ getOut()

    1. true
    2. false

  68. Which of the following methods of JspContext have 2 overloaded versions? (3 correct answers)
    1. findAttribute()
    2. getAttribute()
    3. setAttribute()
    4. removeAttribute()

  69. What is the signature of the method getOut of JspContext? (1 correct answer)
    1. public abstract JspWriter getOut()
    2. public abstract PrintWriter getOut()

  70. The following are all methods of PageContext. (1 correct answer)
          ⇒ getPage()
          ⇒ getSession()
          ⇒ getRequest()
          ⇒ getResponse()
          ⇒ getServletConfig()
          ⇒ getServletContext()

    1. true
    2. false

  71. The following are all fields of PageContext. (1 correct answer)
          ⇒ PAGE_SCOPE
          ⇒ REQUEST_SCOPE
          ⇒ SESSION_SCOPE
          ⇒ APPLICATION_SCOPE

    1. true
    2. false

© 2009-2011 Nikos Pougounias. A free contribution to the Java community. Please distribute it for free. https://nikojava.wordpress.com

Answers

  1. b, f, c, a, d, g, e
  2. a
  3. b
  4. c
  5. d
  6. a
  7. a
  8. b, c
  9. a
  10. a
  11. a
  12. a
  13. a
  14. a
  15. a
  16. a
  17. a
  18. a
  19. a
  20. a
  21. b
  22. b
  23. b
  24. a
  25. a
  26. a
  27. a
  28. b
  29. a
  30. b
  31. a
  32. a
  33. b
  34. a
  35. a
  36. a
  37. a
  38. b
  39. a
  40. b
  41. a
  42. b
  43. b
  44. b
  45. a
  46. a
  47. b
  48. b
  49. c
  50. c
  51. c
  52. b
  53. c
  54. b
  55. c
  56. c
  57. a
  58. a
  59. a
  60. c
  61. a
  62. a
  63. a
  64. a
  65. a
  66. a
  67. a
  68. b, c, d
  69. a
  70. a
  71. a

8 Responses to Free SCWCD Mock Exam for JSPs

  1. Bindu says:

    I could not understand why we get null in second page in question 46.
    If the attribute is in session scope as in question 47 we don’t get null.

  2. ok says:

    input.jsp only has a link of tag named a.it is not a form ,so ,can’t submit.

  3. […] Free SCWCD Mock Exam for JSPs […]

  4. Jerome says:

    Hi !
    I’ve done the mock and don’t agree with some answers….
    Q9 : b) false because isELIgnored is the right spelling : the “I” must be in capital
    Q18 : b) false because it’s said that page is only of type Object

    Can someone confirm please ?🙂
    Thanks a lot for these mocks !

  5. Rohan says:

    Q.48 seems phishy.

    Shouldnt the correct expression be ?

  6. prabha says:

    from Q)23 to Q)56 content is missed

  7. prabha says:

    Q)8
    when i place above tag in jsp i am getting error.
    i hope this won’t work, there is only one way to import packeges i.e

  8. puspita says:

    Hi,
    i have done Q)54 that answer is wrong
    that throws exception

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: