Expression Language QuizS2C Home « Expression Language Quiz

The questions in this quiz on Expression Language are on the topics covered in the EL section of the site. The table below lists the lessons, a description of the lesson content and the quiz question number range.

Lesson Summary

Click on a lesson in the table to go to that lesson for a refresher on the topics for that lesson.

EL Lessons Description Question Range
Lesson 1 - Introduction to ELIn our first lesson on the Expression Language we introduce EL and write our first JSP using EL.1 - 5
Lesson 2 - EL OperatorsThis lesson is about the symbols used in EL for mathematical and logical manipulation which are known as EL operators.6 - 11
Lesson 3 - EL Property AccessIn this lesson we learn how to use EL to access object properties and attribute values from any scope.12 - 16
Lesson 4 - EL Implicit ObjectsIn this lesson we learn about EL implicit objects and their usage.17 - 21
Lesson 5 - Configuring ELIn this lesson we finish our study of the Expression Language by looking at how we can configure our pages for script-free EL or non-EL use.22 - 26

Expression Language Quiz

The quiz below tests your knowledge of the material learnt in the EL section of the site.

Question 1 : What is the main purpose of using EL?
- The main purpose of using EL is to remove Java syntax from JSP pages.
Question 2 : You can use EL alongside Java scripting elements?
- Yes you can use EL alongside Java scripting elements although it's meant as a replacement when used in conjunction with standard and custom actions.
Question 3 : EL expressions are always evaluated from right to leftt.?
- EL expressions are always evaluated from left to right, not right to left.
Question 4 : Which of the following is an invalid EL identifer?
- EL identifiers can start with a letter, the underscore symbol (_) or the dollar sign ($), so <code>*amy1</code> is invalid.
Question 5 : Which of the following is a reserved word and so can't be used as an EL identifer?
- <code>empty</code> is a reserved word and so can't be used as an EL identifer.
Question 6 : What will be the output from the following expression?

<%
   request.setAttribute("a", 15);
   request.setAttribute("b", 6);
%>
${a%b}

- When using modulo <code>%</code> or <code>mod</code> - the remainder is output which in this case is <code>3</code>.
Question 7 : When using the Short-circuit AND (and or &&) if the first operand returns false, the second operand will not be checked?
- When using the Short-circuit AND (<code>and</code> or <code>&&</code>) if the first operand returns false, the second operand will not be checked (short-circuited) and <code>false</code> is returned.
Question 8 : When using the Short-circuit OR (or or ||) if the first operand returns true, the second operand will not be checked?
- When using the Short-circuit OR (<code>or</code> or <code>||</code>) if the first operand returns <code>true</code>, the second operand will not be checked (short-circuited) and <code>true</code> is returned.
Question 9 : What will be the output from the following expression?

${empty ""}

- <code>true</code> will be returned from the expression <code>${empty ""}</code>.
Question 10 : What will be the output from the following conditional operator?

<%
request.setAttribute("a", 6);
request.setAttribute("b", 15);
%>
${(requestScope.a lt requestScope.b)? "lower number" : "higher number"}

- The conditional operator will output <code>lower number</code>.
Question 11 : Which operator has the highest precedence?
- The <code>not</code> operator has a precedence of 1 and so is the highest precedence.
Question 12 : The . operator can be used to access JavaBeans and what other type of object?
- The <code>.</code> operator can be used to access JavaBeans or <code>java.util.Map</code> objects.
Question 13 : The first named variable (before the . operator) is either an attribute within one of the four scopes or what.?
- The first named variable (before the <code>.</code> operator) is either an attribute within one of the four scopes or an EL implicit object.
Question 14 : Which type of property access operator allows us to use non-conforming Java identifers?
- The <code>[]</code> operator allows us to use non-conforming Java identifers.
Question 15 : We can access the property of an object, where that object itself has been returned as the property of another object?
- Yes we can access the property of an object, where that object itself has been returned as the property of an object by chaining the objects together.
Question 16 : Which type of property access operator allows us to use java.util.Map objects?
- We can access<code>java.util.Map</code> objects using either the <code>.</code> or <code>[]</code> operators.
Question 17 : Which EL implicit object is not of type java.util.Map?
- The <code>pageContext</code> EL implicit object is of type <code>javax.servlet.jsp.PageContext</code>, all other EL implicit objects are of type <code>java.util.Map</code>.
Question 18 : Using array like syntax such as ${header.accept[1]} we can access secondary header values using the header EL implicit object.?
- We must use the <code>headerValues</code> EL implicit object to access secondary header values, using syntax such as <code>${headerValues.accept[1]}</code>.
Question 19 : The initParam EL implicit object allows access to servlet initialisation parameters?
- The <code>initParam</code> EL implicit object allows access to context initialisation parameters, not servlet initialisation parameters.
Question 20 : When using the cookie EL implicit object there is no need to iterate over the javax.servlet.http.HTTPServletRequest object to get to the required name?
- When using the <code>cookie</code> EL implicit object there is no need to iterate over the <code>javax.servlet.http.HTTPServletRequest</code> EL implicit object and we can access the name directly using synyax such as <code>${cookie.JSESSIONID.value}</code>.
Question 21 : Which of the following EL implicit object contains variables with the shortest scope?
- The <code>pageScope</code> EL implicit object refers to the current JSP page and so any variables contained within it would have the shortest scope.
Question 22 : Which DD element is used to define global configuration information in a web application for JSP files?
- The <code>jsp-config</code> DD element is used to define global configuration information in a web application for JSP files.
Question 23 : You can invalidate scripting or ignore EL within a JSP page, but not both?
- You can invalidate scripting and ignore EL within a JSP page if you want to configure the JSP page that way.
Question 24 : What happens when we try to run a JSP page that has scripting and the scripting-invalid sub-level element of the jsp-property-group DD element has been set to true?
- When we try to run a JSP page that has scripting and the <code>scripting-invalid</code> sub-level element of the <code>jsp-property-group</code> has been set to <code>true</code> an exception occurs.
Question 25 : What is the only mandatory sub-level element of the jsp-property-group element?
- The <code>url-pattern</code> sub-level element is the only mandatory element within the <code>jsp-property-group</code> element.
Question 26 : What happens when we try to run a JSP page that has El elements and the el-ignored sub-level element of jsp-property-group DD element has been set to true?
- When we try to run a JSP page that has El elements and the <code>el-ignored</code> sub-level element of the <code>jsp-property-group</code> has been set to <code>true</code> any EL elements are output as string literals.
Quiz Progress Bar Please select an answer

What's Next?

The next quiz is on the expression language.

go to home page Homepage go to top of page Top