- Struts 2 Tutorial
- Struts2 - Home
- Struts2 - Basic MVC Architecture
- Struts2 - Overview
- Struts2 - Environment Setup
- Struts2 - Architecture
- Struts2 - Examples
- Struts2 - Configuration
- Struts2 - Actions
- Struts2 - Interceptors
- Struts2 - Result Types
- Struts2 - Value Stack/OGNL
- Struts2 - File Uploads
- Struts2 - Database Access
- Struts2 - Sending Email
- Struts2 - Validations
- Struts2 - Localization
- Struts2 - Type Conversion
- Struts2 - Themes/Templates
- Struts2 - Exception Handling
- Struts2 - Annotations
- Struts 2 Integrations
- Struts2 - Spring
- Struts2 - Tiles
- Struts2 - Hibernate
- Struts 2 Useful Resources
- Struts2 - Questions and Answers
- Struts2 - Quick Guide
- Struts2 - Useful Resources
- Struts2 - Discussion
Struts2 Mock Test
This section presents you various set of Mock Tests related to Struts2. You can download these sample mock tests at your local machine and solve offline at your convenience. Every mock test is supplied with a mock test key to let you verify the final score and grade yourself.
Struts2 Mock Test III
Q 1 - What is the purpose of @After annotation?
A - This annotation is a collection of results.
B - This annotation have the name that correspond to the outcome of the execute method.
C - This annotation is used to decorate the execute() method.
D - This annotation marks a action method that needs to be called after the main action method.
Answer : D
Explanation
The @After annotation marks a action method that needs to be called after the main action method and the result was executed. Return value is ignored.
Q 2 - What is the purpose of @Before annotation?
B - This annotation marks a action method that needs to be executed before the result.
D - This annotation checks that a date field has a value within a specified range.
Answer : A
Explanation
The @Before annotation marks a action method that needs to be called before the main action method and the result was executed. Return value is ignored.
Q 3 - What is the purpose of @BeforeResult annotation?
B - This annotation marks a action method that needs to be executed before the result.
D - This annotation checks that a date field has a value within a specified range.
Answer : B
Explanation
The @BeforeResult annotation marks a action method that needs to be executed before the result. Return value is ignored.
Q 4 - What is the purpose of @ConversionErrorFieldValidator annotation?
B - This annotation marks a action method that needs to be executed before the result.
D - This annotation checks that a date field has a value within a specified range.
Answer : C
Explanation
This validation annotation checks if there are any conversion errors for a field and applies them if they exist.
Q 5 - What is the purpose of @DateRangeFieldValidator annotation?
B - This annotation marks a action method that needs to be executed before the result.
D - This annotation checks that a date field has a value within a specified range.
Answer : D
Explanation
This validation annotation checks that a date field has a value within a specified range.
Q 6 - What is the purpose of @DoubleRangeFieldValidator annotation?
A - This annotation checks that a double field has a value within a specified range.
B - This annotation checks that a field is a valid e-mail address if it contains a non-empty String.
C - This annotation validates a supplied regular expression.
D - This annotation checks that a numeric field has a value within a specified range.
Answer : A
Explanation
This validation annotation checks that a double field has a value within a specified range. If neither min nor max is set, nothing will be done.
Q 7 - What is the purpose of @EmailValidator annotation?
A - This annotation checks that a double field has a value within a specified range.
B - This annotation checks that a field is a valid e-mail address if it contains a non-empty String.
C - This annotation validates a supplied regular expression.
D - This annotation checks that a numeric field has a value within a specified range.
Answer : B
Explanation
This validation annotation checks that a field is a valid e-mail address if it contains a non-empty String.
Q 8 - What is the purpose of @ExpressionValidator annotation?
A - This annotation checks that a double field has a value within a specified range.
B - This annotation checks that a field is a valid e-mail address if it contains a non-empty String.
C - This annotation validates a supplied regular expression.
D - This annotation checks that a numeric field has a value within a specified range.
Answer : C
Explanation
This non-field level validator validates a supplied regular expression.
Q 9 - What is the purpose of @IntRangeFieldValidator annotation?
A - This annotation checks that a double field has a value within a specified range.
B - This annotation checks that a field is a valid e-mail address if it contains a non-empty String.
C - This annotation validates a supplied regular expression.
D - This annotation checks that a numeric field has a value within a specified range.
Answer : D
Explanation
This validation annotation checks that a numeric field has a value within a specified range. If neither min nor max is set, nothing will be done.
Q 10 - What is the purpose of @RegexFieldValidator annotation?
A - This annotation validates a string field using a regular expression.
B - This annotation checks that a field is a valid e-mail address if it contains a non-empty String.
C - This annotation validates a supplied regular expression.
D - This annotation checks that a numeric field has a value within a specified range.
Answer : A
Explanation
This annotation validates a string field using a regular expression.
Q 11 - What is the purpose of @RequiredFieldValidator annotation?
A - This annotation validates a string field using a regular expression.
B - This annotation checks that a field is non-null.
C - This annotation validates a supplied regular expression.
D - This annotation checks that a numeric field has a value within a specified range.
Answer : B
Explanation
This validation annotation checks that a field is non-null. The annotation must be applied at method level.
Q 12 - What is the purpose of @RequiredStringValidator annotation?
A - This annotation validates a string field using a regular expression.
B - This annotation checks that a field is non-null.
C - This annotation checks that a String field is not empty
D - This annotation checks that a numeric field has a value within a specified range.
Answer : C
Explanation
This validation annotation checks that a String field is not empty (i.e. non-null with a length > 0).
Q 13 - What is the purpose of @StringLengthFieldValidator annotation?
A - This annotation validates a string field using a regular expression.
B - This annotation checks that a field is non-null.
C - This annotation checks that a String field is not empty
D - This annotation checks that a String field is of the right length.
Answer : D
Explanation
This validator checks that a String field is of the right length. It assumes that the field is a String. If neither minLength nor maxLength is set, nothing will be done.
Q 14 - What is the purpose of @UrlValidator annotation?
A - This annotation checks that a field is a valid URL.
B - This annotation checks that a field is non-null.
C - This annotation checks that a String field is not empty
D - This annotation checks that a String field is of the right length.
Answer : A
Explanation
This validator checks that a field is a valid URL.
Q 15 - What is the purpose of @Validations annotation?
A - This annotation checks that a field is a valid URL.
B - This annotation is used to nest several annotations of same type.
C - This annotation checks that a String field is not empty
D - This annotation checks that a String field is of the right length.
Answer : B
Explanation
If you want to use several annotations of the same type, these annotation must be nested within the @Validations() annotation.
Q 16 - What is the purpose of @CustomValidator annotation?
A - This annotation checks that a field is a valid URL.
B - This annotation is used to nest several annotations of same type.
C - This annotation can be used for custom validators.
D - This annotation checks that a String field is of the right length.
Answer : C
Explanation
This annotation can be used for custom validators. Use the ValidationParameter annotation to supply additional params.
Q 17 - What is the purpose of @Conversion Annotation?
A - This annotation checks that a field is a valid URL.
B - This annotation is used to nest several annotations of same type.
C - This annotation can be used for custom validators.
D - This annotation is a marker annotation for type conversions at Type level.
Answer : D
Explanation
This is a marker annotation for type conversions at Type level. The Conversion annotation must be applied at Type level.
Q 18 - What is the purpose of @CreateIfNull Annotation?
A - This annotation sets the CreateIfNull for type conversion.
B - This annotation is used to nest several annotations of same type.
C - This annotation can be used for custom validators.
D - This annotation is a marker annotation for type conversions at Type level.
Answer : A
Explanation
This annotation sets the CreateIfNull for type conversion. The CreateIfNull annotation must be applied at field or method level.
Q 19 - What is the purpose of @Element Annotation?
A - This annotation sets the CreateIfNull for type conversion.
B - This annotation sets the Element for type conversion.
C - This annotation can be used for custom validators.
D - This annotation is a marker annotation for type conversions at Type level.
Answer : B
Explanation
This annotation sets the Element for type conversion. The Element annotation must be applied at field or method level.
Q 20 - What is the purpose of @Key Annotation?
A - This annotation sets the CreateIfNull for type conversion.
B - This annotation sets the Element for type conversion.
C - This annotation sets the Key for type conversion.
D - This annotation is a marker annotation for type conversions at Type level.
Answer : C
Explanation
This annotation sets the Key for type conversion. The Key annotation must be applied at field or method level.
Q 21 - What is the purpose of @KeyProperty Annotation?
A - This annotation sets the CreateIfNull for type conversion.
B - This annotation sets the Element for type conversion.
C - This annotation sets the Key for type conversion.
D - This annotation sets the KeyProperty for type conversion.
Answer : D
Explanation
This annotation sets the KeyProperty for type conversion. The KeyProperty annotation must be applied at field or method level.
Q 22 - What is the purpose of @TypeConversion Annotation?
A - This annotation sets the CreateIfNull for type conversion.
B - This annotation sets the Element for type conversion.
C - This annotation sets the Key for type conversion.
D - This annotation is used for class and application wide conversion rules.
Answer : A
Explanation
This annotation annotation is used for class and application wide conversion rules. The TypeConversion annotation can be applied at property and method level.
Q 23 - Which of the following tag performs basic if-else conditional flow?
Answer : A
Explanation
These tags perform basic condition flow found in every language. 'If' tag could be used by itself or with 'Else If' Tag and/or single/multiple 'Else' Tag.
Q 24 - Which of the following tag will iterate over a value?
Answer : B
Explanation
These iterator will iterate over a value. An iterable value can be any of: java.util.Collection, java.util.Iterator. While iterating over an iterator, you can use Sort tag to sort the result or SubSet tag to to get a sub set of the list or array.
Q 25 - Which of the following tag takes two or more lists as parameters and merge them all together?
Answer : C
Explanation
These merge tag take two or more lists as parameters and merge them all together.
Answer Sheet
Question Number | Answer Key |
---|---|
1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | |
14 | |
15 | |
16 | |
17 | |
18 | |
19 | |
20 | |
21 | |
22 | |
23 | |
24 | |
25 |