Question
Java | Answer them correctly 21. Given: 1. 8. Which, inserted at line 18, are valid and evaluate to c? (Choose all that apply.) (a)${list[2]}
Java | Answer them correctly
21. Given:
1. <% java.util.List list = new java.util.ArrayList();
2. list.add("a");
3. list.add("2");
4. list.add("c");
5. request.setAttribute("list", list);
6. request.setAttribute("listIdx", "1");
7. %>
8. <%-- insert code here --%>
Which, inserted at line 18, are valid and evaluate to c? (Choose all that apply.)
(a)${list[2]}
(b)${list.listIdx+1}
(c)${list[listIdx+1]}
(d)${list[listIdx + 1]}
(e)${list[list[listIdx]]}
22. In a JSP, we want to compare two integers stored in the request scope using JSTL. Assume that these two integers are stored under the attributes num1 and num2. If these two numbers are equal, print out the string same; otherwise, print out the string different.
Ans:
23. In a JSP, we want to compare two integers stored in the URL parameters using JSTL. Assume that these two integers are stored under the parameter names num1 and num2. If these two numbers are equal, print out the string same; otherwise, print out the string different.
Ans:
24. Given:
0. public class MyBean {
1. private java.util.Map params;
2. private java.util.List objects;
3. private String name;
4. public java.util.Map getParams(){return params;}
5. public String getName(){return name;}
6. public java.util.List getObjects(){return objects;}
7. }
Which will cause errors (assume that an attribute named mybean can be found, and is of type MyBean)? (Choose all that apply.)
(a)${mybean.name}
(b)${mybean["name"]}
(c)${mybean.objects.a}
(d)${mybean["params"].a}
(e)${mybean.params["a"]}
25. Given a JSP page:
1. The user has sufficiently logged in or out:
2. ${param.loggedIn or param.loggedOut}.
If the request includes the query string loggedOut=true, what will be this state-ments displayed value?
(a)The user has sufficiently logged in or out: false.
(b)The user has sufficiently logged in or out: true.
(c)The user has sufficiently logged in or out: ${param.loggedIn or param.loggedOut}.
(d)The user has sufficiently logged in or out: param.loggedIn or param.loggedOut.
(e)The user has sufficiently logged in or out: or true.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started