Spring Questions and Answers – Bean validation and creating excel and pdf

«
»

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

Answer: d
Explanation: You can validate Java beans in a web application using annotations based on the JSR-303 standard.
advertisement

2. JSR-303 or bean validation can access beans through annotations.
a) True
b) False
View Answer

Answer: a
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

Answer: c
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

Answer: b
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

Answer: b
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

Answer: b
Explanation: @Size annotation used to indicate a field has to have a minimum of 2 characters.
advertisement

7. Annotation which receives a value in the form regexp=”[email protected]+\\.[a-z]+”.
a) @Pattern
b) @EmailRecognizer
c) @Email
d) @Null
View Answer

Answer: a
Explanation: @Pattern annotation receives a value in the form regexp=”[email protected]+\\.[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

Answer: a
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

Answer: b
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
b) javax.validation.ConstraintViolation
View Answer

Answer: d
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

Answer: c
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

Answer: b
Explanation: Spring integrates the generation of Excel and PDF files into its MVC framework.
advertisement

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

Answer: c
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

Answer: d
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

Answer: a
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.

advertisement
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage, Advanced C Programming, SAN Storage Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him @ LinkedIn