This practice exam focuses on EL. For those using Head First Servlets and JSP, 2nd Edition it provides a lot of practice for the last part of chapter 8.
- In EL you may use the . operator to access maps and beans.
- true
- false
- In EL you may use the [] operator to access maps, beans, lists and arrays.
- true
- false
- Which of the following are EL implicit objects? (4 correct answers)
- pageScope
- requestScope
- sessionScope
- contextScope
- applicationScope
- Which of the following are EL implicit objects? (2 correct answers)
- param
- parameter
- params
- parameters
- paramValues
- parameterValues
- Which of the following are EL implicit objects? (1 correct answer)
- initParam
- servletParam
- contextParam
- applicationParam
- Which of the following EL implicit objects are maps? (3 correct answers)
- cookie
- pageContext
- headerValues
- applicationScope
- What is the output of the following code? (1 correct answer)
<% session.setAttribute("name", "Diogenes"); %> ${session.name}- “Diogenes”
- “”
- What is the output of the following code? (1 correct answer)
<% session.setAttribute("name", "Diogenes"); %> ${sessionScope.name}- “Diogenes”
- “”
- What is the output of the following code? (1 correct answer)
<% session.setAttribute("name", "Diogenes"); %> ${sessionScope[name]}- “Diogenes”
- “”
- 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 ${yourname} !! </body> </html>What is the output when the form is submitted? (1 correct answer)
- “Hello !!”
- “Hello Bond !!”
- 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.yourname} !! </body> </html>What is the output when the form is submitted? (1 correct answer)
- “Hello !!”
- “Hello Bond !!”
- 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 ${requestMap.yourname} !! </body> </html>What is the output when the form is submitted? (1 correct answer)
- “Hello !!”
- “Hello Bond !!”
- 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 ${requestScope.yourname} !! </body> </html>What is the output when the form is submitted? (1 correct answer)
- “Hello !!”
- “Hello Bond !!”
- 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 ${pageScope.yourname} !! </body> </html>What is the output when the form is submitted? (1 correct answer)
- “Hello !!”
- “Hello Bond !!”
- 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 ${param.yourname} !! </body> </html>What is the output when the form is submitted? (1 correct answer)
- “Hello !!”
- “Hello Bond !!”
- 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 ${param[yourname]} !! </body> </html>What is the output when the form is submitted? (1 correct answer)
- “Hello !!”
- “Hello Bond !!”
- 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 ${paramValues.yourname} !! </body> </html>What is the output when the form is submitted? (1 correct answer)
- “Hello !!”
- “Hello Bond !!”
- None of the above.
- 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 ${paramValues[yourname]} !! </body> </html>What is the output when the form is submitted? (1 correct answer)
- “Hello !!”
- “Hello Bond !!”
- None of the above.
- 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 ${paramValues.yourname.0} !! </body> </html>What is the output when the form is submitted? (1 correct answer)
- “Hello !!”
- “Hello Bond !!”
- None of the above.
- 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 ${paramValues.yourname[0]} !! </body> </html>What is the output when the form is submitted? (1 correct answer)
- “Hello !!”
- “Hello Bond !!”
- None of the above.
- What is the output of this page? (1 correct answer)
<html> <body> Number ${14 + 3} </body> </html>- “Number “
- “Number 17″
- What is the output of this page? (1 correct answer)
<html> <body> Number ${"14" + 3} </body> </html>- “Number 17″
- “Number 143″
- What is the output of this page? (1 correct answer)
<html> <body> Result is ${2 > 3} </body> </html>- “Result is true”
- “Result is false”
- What is the output of this page? (1 correct answer)
<html> <body> Result is ${"2" > 3} </body> </html>- “Result is true”
- “Result is false”
- What is the output of this page? (1 correct answer)
<html> <body> Result is ${"a" > "b"} </body> </html>- “Result is true”
- “Result is false”
- What is the output of this page? (1 correct answer)
<html> <body> Result is ${"a" < "b"} </body> </html>- “Result is true”
- “Result is false”
- What is the output of this page? (1 correct answer)
<html> <body> Result is ${a < b} </body> </html>- “Result is true”
- “Result is false”
- What is the output of this page? (1 correct answer)
<html> <body> Result is ${"a literal"} </body> </html>- “Result is “
- “Result is a literal”
- What is the output of this page? (1 correct answer)
<html> <body> Result is ${'a literal'} </body> </html>- “Result is “
- “Result is a literal”
- What is the output of this page? (1 correct answer)
<html> <body> Result is ${"a literal" + " indeed."} </body> </html>- “Result is a literal indeed.”
- An exception is thrown at runtime.
- What is the output of this page? (1 correct answer)
<html> <body> Result is ${2 / 0} </body> </html>- “Result is Infinity”
- An exception is thrown at runtime.
- What is the output of this page? (1 correct answer)
<html> <body> Result is ${2 mod 0} </body> </html>- “Result is Infinity”
- An exception is thrown at runtime.
- What is the output of this page? (1 correct answer)
<html> <body> Result is ${null mod 1} </body> </html>- “Result is 0″
- “Result is null”
- An exception is thrown at runtime.
- What is the output of this page? (1 correct answer)
<html> <body> Result is ${null + 1} </body> </html>- “Result is 0″
- “Result is 1″
- “Result is null”
- What is the output of this page? (1 correct answer)
<html> <body> Result is ${true and null} </body> </html>- “Result is true”
- “Result is false”
- What is the output of this page? (1 correct answer)
<html> <body> Result is ${empty null} </body> </html>- “Result is true”
- “Result is false”
- What is the output of this page? (1 correct answer)
<% request.setAttribute("list", new String[100]); %> <html> <body> Result is ${empty list} </body> </html>- “Result is true”
- “Result is false”
- What is the output of this page? (1 correct answer)
<% request.setAttribute("list", new String[0]); %> <html> <body> Result is ${empty list} </body> </html>- “Result is true”
- “Result is false”
- What is the output of this page? (1 correct answer)
<% String[] names = new String[]{"Rihanna", "Lopez", "Kylie"}; request.setAttribute("names", names); %> <html> <body> Hey ${request.names}!! </body> </html>- “Hey !!”
- “Hey null!!”
- “Hey Rihanna!!”
- None of the above.
- What is the output of this page? (1 correct answer)
<% String[] names = new String[]{"Rihanna", "Lopez", "Kylie"}; request.setAttribute("names", names); %> <html> <body> Hey ${request.names[0]}!! </body> </html>- “Hey !!”
- “Hey Rihanna!!”
- None of the above.
- What is the output of this page? (1 correct answer)
<% String[] names = new String[]{"Rihanna", "Lopez", "Kylie"}; request.setAttribute("names", names); %> <html> <body> Hey ${requestScope.names[0]}!! </body> </html>- “Hey !!”
- “Hey Rihanna!!”
- None of the above.
- What is the output of this page? (1 correct answer)
<% String[] names = new String[]{"Rihanna", "Lopez", "Kylie"}; request.setAttribute("names", names); %> <html> <body> Hey ${requestScope.names[12 - 12]}!! </body> </html>- “Hey !!”
- “Hey Rihanna!!”
- None of the above.
- What is the output of this page? (1 correct answer)
<% String[] names = new String[]{"Rihanna", "Lopez", "Kylie"}; request.setAttribute("names", names); %> <html> <body> Hey ${requestScope.names[<%= names.length - 2%>]}!! </body> </html>- “Hey !!”
- “Hey Rihanna!!”
- None of the above.
- What is the output of this page? (1 correct answer)
<% String[] names = new String[]{"Rihanna", "Lopez", "Kylie"}; request.setAttribute("names", names); %> <html> <body> Hey ${requestScope["names"]}!! </body> </html>- “Hey !!”
- “Hey Rihanna!!”
- None of the above.
- What is the output of this page? (1 correct answer)
<% String[] names = new String[]{"Rihanna", "Lopez", "Kylie"}; request.setAttribute("names", names); %> <html> <body> Hey ${requestScope["names"].0}!! </body> </html>- “Hey !!”
- “Hey Rihanna!!”
- None of the above.
- What is the output of this page? (1 correct answer)
<% String[] names = new String[]{"Rihanna", "Lopez", "Kylie"}; request.setAttribute("names", names); %> <html> <body> Hey ${requestScope["names"][0]}!! </body> </html>- “Hey !!”
- “Hey Rihanna!!”
- None of the above.
- What is the output of this page? (1 correct answer)
<% String[] names = new String[]{"Rihanna", "Lopez", "Kylie"}; request.setAttribute("names", names); %> <html> <body> Hey ${pageScope["names"][0]}!! </body> </html>- “Hey !!”
- “Hey Rihanna!!”
- None of the above.
- What is the output of this page? (1 correct answer)
<% String[] names = new String[]{"Rihanna", "Lopez", "Kylie"}; request.setAttribute("names", names); %> <html> <body> Hey ${names[0]}!! </body> </html>- “Hey !!”
- “Hey Rihanna!!”
- None of the above.
- What is the output of this page? (1 correct answer)
<% java.util.List names = new java.util.LinkedList(); names.add("Rihanna"); names.add("Lopez"); names.add("Kylie"); request.setAttribute("names", names); %> <html> <body> Hey ${names[0]}!! </body> </html>- “Hey !!”
- “Hey Rihanna!!”
- None of the above.
- What is the output of this page? (1 correct answer)
<% java.util.List names = new java.util.LinkedList(); names.add("Rihanna"); names.add("Lopez"); names.add("Kylie"); request.setAttribute("names", names); %> <html> <body> Hey ${names[-1]}!! </body> </html>- “Hey !!”
- “Hey Rihanna!!”
- None of the above.
- What is the output of this page? (1 correct answer)
<% java.util.Map names = new java.util.HashMap(); names.put("0", "Rihanna"); names.put("1", "Lopez"); names.put("2", "Kylie"); request.setAttribute("names", names); %> <html> <body> Hey ${names["0"]}!! </body> </html>- “Hey !!”
- “Hey Rihanna!!”
- None of the above.
- What is the output of this page? (1 correct answer)
<% java.util.Map names = new java.util.HashMap(); names.put("0", "Rihanna"); names.put("1", "Lopez"); names.put("2", "Kylie"); request.setAttribute("names", names); %> <html> <body> Hey ${names[0]}!! </body> </html>- “Hey !!”
- “Hey Rihanna!!”
- None of the above.
- What is the output of this page? (1 correct answer)
<% request.setAttribute("1007", Integer.valueOf(10)); %> <html> <body> Number is ${1007}!! </body> </html>- “Number is !!”
- “Number is 10!!”
- “Number is 1007!!”
- What is the output of this page? (1 correct answer)
<% request.setAttribute("1007", Integer.valueOf(10)); %> <html> <body> Number is ${"1007"}!! </body> </html>- “Number is !!”
- “Number is 10!!”
- “Number is 1007!!”
- What is the output of this page? (1 correct answer)
<% request.setAttribute("1007", Integer.valueOf(10)); %> <html> <body> Number is ${requestScope["1007"]}!! </body> </html>- “Number is !!”
- “Number is 10!!”
- “Number is 1007!!”
- Consider the following code.
package model; public class Person { private String fullName; public String getFullName() { return fullName; } public void setFullName(String fullName) { this.fullName = fullName; } }<jsp:useBean id="person" class="model.Person"> <jsp:setProperty name="person" property="fullName" value="Josh Childress" /> </jsp:useBean> <html> <body> Hey you ${person.fullName}! </body> </html>What is the output? (1 correct answer)
- Hey you !
- Hey you Josh Childress!
- None of the above.
- Consider the following code.
package model; public class Person { private String name; public String getFullName() { return name; } public void setFullName(String fullName) { this.name = fullName; } }<jsp:useBean id="person" class="model.Person"> <jsp:setProperty name="person" property="fullName" value="Josh Childress" /> </jsp:useBean> <html> <body> Hey you ${person.fullName}! </body> </html>What is the output? (1 correct answer)
- Hey you !
- Hey you Josh Childress!
- None of the above.
- Consider the following code.
package model; public class Person { private String fullName; public String getFullName() { return fullName; } public void setFullName(String fullName) { this.fullName = fullName; } }<jsp:useBean id="person" class="model.Person"> <jsp:setProperty name="person" property="fullName" value="Josh Childress" /> </jsp:useBean> <html> <body> Hey you ${person}! </body> </html>What is the output? (1 correct answer)
- Hey you !
- Hey you Josh Childress!
- None of the above.
- Consider the following code.
package model; public class Person { private String fullName; public String getFullName() { return fullName; } public void setFullName(String fullName) { this.fullName = fullName; } public String toString() { return fullName; } }<jsp:useBean id="person" class="model.Person"> <jsp:setProperty name="person" property="fullName" value="Josh Childress" /> </jsp:useBean> <html> <body> Hey you ${person}! </body> </html>What is the output? (1 correct answer)
- Hey you !
- Hey you Josh Childress!
- None of the above.
- What is the output of this code? (1 correct answer)
<% request.setAttribute("email", "request@info"); session.setAttribute("email", "session@info"); pageContext.setAttribute("email", "page@info"); application.setAttribute("email", "application@info"); %> <html> <body> Contact an administrator at ${email}. </body> </html>- Contact an administrator at page@info.
- Contact an administrator at session@info.
- Contact an administrator at request@info.
- Contact an administrator at application@info.
- What is the output of this code? (1 correct answer)
<% session.setAttribute("email", "session@info"); application.setAttribute("email", "application@info"); %> <html> <body> Contact an administrator at ${email}. </body> </html>- Contact an administrator at session@info.
- Contact an administrator at application@info.
- What is the output of this code? (1 correct answer)
<% request.setAttribute("email", "request@info"); session.setAttribute("email", "session@info"); %> <html> <body> Contact an administrator at ${email}. </body> </html>- Contact an administrator at request@info.
- Contact an administrator at session@info.
- What is the output of this code? (1 correct answer)
<% request.setAttribute("email", null); session.setAttribute("email", "session@info"); %> <html> <body> Contact an administrator at ${email}. </body> </html>- Contact an administrator at .
- Contact an administrator at session@info.
© 2009 Nikos Pougounias. A free contribution to the Java community. Please distribute it for free. http://nikojava.wordpress.com
Answers
- a
- a
- a, b, c, e
- a, e
- a
- a, c, d
- b
- a
- b
- a
- a
- a
- a
- a
- b
- a
- c
- a
- c
- b
- b
- a
- b
- b
- b
- a
- b
- b
- b
- b
- a
- b
- a
- b
- b
- a
- b
- a
- a
- a
- b
- b
- c
- c
- c
- b
- a
- b
- b
- a
- b
- a
- c
- c
- b
- b
- b
- c
- b
- a
- a
- a
- b
Thanks for the questions.Quite interesting.
[...] Free SCWCD Mock Exam for EL [...]