250+ TOP MCQs on Bean validation and creating excel and pdf and Answers

Java Spring Multiple Choice Questions & Answers (MCQs) 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

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

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

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

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

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

Answer: b
Clarification: @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=”[email protected]+\.[a-z]+”.
a) @Pattern
b) @EmailRecognizer
c) @Email
d) @Null

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

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

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

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

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

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

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

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

Answer: a
Clarification: PDF files are generated by the iText library (http://www.lowagie.com/iText/), and the corresponding view class is AbstractPdfView.

Leave a Reply

Your email address will not be published. Required fields are marked *