- 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 II
Q 1 - Which of the following is correct about the Named Objects?
A - There are various temporary objects which are created during execution of a page.
B - The current model object is placed before the action on the value stack.
Answer : C
Explanation
These objects include #application, #session, #request, #attr and #parameters and refer to the corresponding servlet scopes.
Q 2 - Which of the following is correct about the OGNL?
Answer : C
Explanation
Both of the above options are correct.
Q 3 - Which of the following components are available using ActionContext map?
A - application - application scoped variables.
B - session - session scoped variables.
Answer : D
Explanation
All of the above options are correct.
Q 4 - Which interceptor is responsible for file upload support?
Answer : A
Explanation
File uploading in Struts is possible through a pre-defined interceptor called FileUpload interceptor which is available through the org.apache.struts2.interceptor.
Q 5 - What are the Struts2 configuration properties that control file uploading process?
Answer : D
Explanation
All of the above are Struts2 configuration properties that control file uploading process.
Q 6 - What are the Struts2 error message keys that can come during file uploading process?
A - struts.messages.error.uploading
B - struts.messages.error.file.too.large
Answer : D
Explanation
All of the above are Struts2 error message keys that can come during file uploading process.
Q 7 - Can you override the default error message that can come during file uploading process?
Answer : A
Explanation
You can override the text of these messages in WebContent/WEB-INF/classes/messages.properties resource files.
Q 8 - Which of the following is correct about Struts 2 validation framework?
Answer : C
Explanation
Both of the above statements are correct.
Q 9 - How Struts 2 validation works?
C - If any errors have been added then Struts 2 will not proceed to call the execute method.
Answer : D
Explanation
All of the above statements are correct.
Q 10 - How Struts 2 validation works?
B - Struts 2 will automatically add the error messages just above the form filed.
Answer : C
Explanation
Both of the above statements are correct.
Q 11 - What should be the name of xml file used for validation in struts?
Answer : A
Explanation
The xml file needs to be named '[action-class]'-validation.xml.
Q 12 - What types of validators are available in xml based validation in struts2?
Answer : D
Explanation
All of the above validators are available in xml based validation in struts2.
Q 13 - What types of validators are available in xml based validation in struts2?
Answer : D
Explanation
All of the above validators are available in xml based validation in struts2.
Q 14 - Which of the following is true about internationalization?
B - The internationalization process is sometimes called translation or localization enablement.
Answer : C
Explanation
Both of the above statements are correct.
Q 15 - In which of the following internationalization (i18n) support is present in Struts 2?
Answer : D
Explanation
Struts2 provides localization ie. internationalization (i18n) support through resource bundles, interceptors and tag libraries in all of the above places.
Q 16 - Which class of struts is responsible to converts data types from string?
Answer : A
Explanation
StrutsTypeConverter class tells Struts how to convert Environment to a String and vice versa by overriding two methods convertFromString() and convertToString().
Q 17 - Which class of struts is responsible to convert String to data types?
Answer : A
Explanation
StrutsTypeConverter class tells Struts how to convert Environment to a String and vice versa by overriding two methods convertFromString() and convertToString().
Q 18 - Which of the following theme comes bundled with struts 2?
Answer : D
Explanation
All of the above themes comes bundled with struts 2.
Q 19 - Which of the following theme represents minimal theme with no "bells and whistles".?
Answer : A
Explanation
simple theme - A minimal theme with no "bells and whistles". For example, the textfield tag renders the HTML tag without a label, validation, error reporting, or any other formatting or functionality.
Q 20 - Which of the following theme is the default theme used by Struts 2?
Answer : B
Explanation
xhtml theme - This is the default theme used by Struts 2 and provides all the basics that the simple theme provides and adds several features like standard two-column table layout for the HTML, Labels for each of the HTML, Validation and error reporting etc.
Q 21 - Which of the following theme provides all the basics that the simple theme provides and adds several features like standard two-column CSS-based layout?
Answer : C
Explanation
css_xhtml theme - This theme provides all the basics that the simple theme provides and adds several features like standard two-column CSS-based layout, using for the HTML Struts Tags, Labels for each of the HTML Struts Tags, placed according to the CSS stylesheet.
Q 22 - Which of the following is true about exception handling in Structs?
A - Struts makes the exception handling easy by the use of the "exception" interceptor.
Answer : D
Explanation
All of the above statement are true.
Q 23 - What is the purpose of @Results 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 : A
Explanation
A @Results annotation is a collection of results. Under the @Results annotation, we can have multiple @Result annotations.
Q 24 - What is the purpose of @Result 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 : B
Explanation
The @result annotations have the name that correspond to the outcome of the execute method. They also contain a location as to which view should be served corresponding to return value from execute().
Q 25 - What is the purpose of @Action 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 : C
Explanation
This is used to decorate the execute() method. The Action method also takes in a value which is the URL on which the action is invoked.
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 |