This set of Java Spring Multiple Choice Questions & Answers (MCQs) focuses on “Bean validation and creating excel and pdf”.
1. To validate Java beans in a web application using annotations.
a) XML
b) Java Based
c) JAR-303 standard
d) All of the mentioned
View Answer
Explanation: You can validate Java beans in a web application using annotations based on the JSR-303 standard.
2. JSR-303 or bean validation can access beans through annotations.
a) True
b) False
View Answer
Explanation: JSR-303 or bean validation is a specification whose objective is to standardize the validation of Java beans through annotations.
3. For validating beans Spring supports.
a) ad-hoc technique
b) jsr-303
c) all of the mentioned
d) none of the mentioned
View Answer
Explanation: This requires you to extend one of the Spring framework’s classes to create a validator class for a particular type of Java bean.
4. JSR-303 can’t access java beans directly.
a) True
b) False
View Answer
Explanation: The objective of the JSR-303 standard is to use annotations directly in a Java bean class.
5. Annotation which indicates a field cannot be a null.
a) @NotNULL
b) @NotNull
c) All of the mentioned
d) None of the mentioned
View Answer
Explanation: The @NotNull annotation, which indicates a field cannot be null .
6. Annotation used to indicate a field has to have a minimum of 2 characters.
a) @NotNull
b) @Size
c) @MaxSize
d) @size
View Answer
Explanation: @Size annotation used to indicate a field has to have a minimum of 2 characters.
7. Annotation which receives a value in the form regexp=”.+@.+\\.[a-z]+”.
a) @Pattern
b) @EmailRecognizer
c) @Email
d) @Null
View Answer
Explanation: @Pattern annotation receives a value in the form regexp=”.+@.+\\.[a-z]+”.
8. A field named validator is of type.
a) javax.validation.Validator
b) javax.validation.ValidatorFactory
c) javax.validation.ValidatorFactor
d) none of the mentioned
View Answer
Explanation: The first addition to the controller is a field named validator of the type javax.validation.Validator.
9. Validator field is not assigned to any bean, but rather a factory class of the type.
a) javax.validation.Validator
b) javax.validation.ValidatorFactory
c) javax.validation.ValidatorFactor
d) none of the mentioned
View Answer
Explanation: This is how JSR-303 validation works. The assignment process is done inside the controller’s constructor.
10. To hold any errors detected from validating the instance of beans.
a) javax.validation.Validator
b) javax.validation.ValidatorFactory
c) javax.validation.ValidatorFactor
d) javax.validation.ConstraintViolation
View Answer
Explanation: Set of the type javax.validation.ConstraintViolation to hold any errors detected from validating the instance of the Person object.
11. To use JSR-303 bean validation in a web application, dependencies to be added in maven.
a) javax.validation
b) org.hibernate
c) all of the mentioned
d) none of the mentioned
View Answer
Explanation: you must add above mentioned dependencies to an implementation to your CLASSPATH.
12. Spring doesn’t cope up with pdf and excel views.
a) True
b) False
View Answer
Explanation: Spring integrates the generation of Excel and PDF files into its MVC framework.
13. Spring MVC supports generating Excel files using which of the following libraries.
a) Apache POI library
b) JExcelAPI library
c) All of the mentioned
d) None of the mentioned
View Answer
Explanation: Spring MVC supports generating Excel files using either the Apache POI library (http://poi.apache.org/) or the JExcelAPI library (http://jexcelapi.sourceforge.net/).
14. The view classes for Excel view is/are:-
a) AbstractExcelView
b) AbstractJExcelView
c) None of the mentioned
d) All of the mentioned
View Answer
Explanation: The corresponding view classes are AbstractExcelView and AbstractJExcelView.
15. Spring MVC supports generating PDF files using which of the following libraries.
a) iText library
b) iJText library
c) all of the mentioned
d) none of the mentioned
View Answer
Explanation: PDF files are generated by the iText library (http://www.lowagie.com/iText/), and the corresponding view class is AbstractPdfView.
Sanfoundry Global Education & Learning Series – Java Spring.
To practice all areas of Java Spring, here is complete set of 1000+ Multiple Choice Questions and Answers.
- Apply for Programming Internship
- Apply for Spring Internship
- Practice Programming MCQs
- Check Information Technology Books
- Check Spring Books