Loading

Quipoin Menu

Learn • Practice • Grow

spring / Form Handling & Validation
mcq
Direction: Choose the correct option

Q1.

What is the purpose of @ModelAttribute in form handling?
A. To bind form fields to a model object
B. To validate the form
C. To render the form
D. To handle form submission
Direction: Choose the correct option

Q2.

Which tag library is commonly used for Spring MVC forms?
A. Spring Form Tag Library
B. JSTL
C. Thymeleaf
D. Any of the above
Direction: Choose the correct option

Q3.

What does tag in Spring MVC do?
A. Renders an HTML form that binds to a model attribute
B. Creates a form with CSRF token
C. Both A and B
D. None
Direction: Choose the correct option

Q4.

Which annotation is used for validation constraints (e.g., not null, size)?
A. @NotNull
B. @Size
C. @Valid
D. All of the above
Direction: Choose the correct option

Q5.

What does @Valid annotation do in a controller method?
A. Triggers validation of the annotated object
B. Marks a valid object
C. Enables validation for all parameters
D. None
Direction: Choose the correct option

Q6.

How do you access validation errors in a controller?
A. Using BindingResult parameter after the validated object
B. Using Errors parameter
C. Both A and B
D. Using @ValidResult
Direction: Choose the correct option

Q7.

What is the purpose of BindingResult?
A. To hold the result of validation and data binding
B. To bind request parameters
C. To render errors in view
D. All of the above
Direction: Choose the correct option

Q8.

How do you display error messages in a JSP form?
A. <form:errors path='fieldName'/>
B. <spring:errors>
C. <c:if test='${errors}'
D. All
Direction: Choose the correct option

Q9.

What is a custom validator in Spring?
A. A class implementing Validator interface
B. A method annotated with @InitBinder
C. Both A and B
D. None
Direction: Choose the correct option

Q10.

What does @InitBinder do?
A. Configures data binding and validators for a controller
B. Initializes a binder
C. Binds request parameters
D. None