Loading

Quipoin Menu

Learn • Practice • Grow

spring / Spring MVC CRUD
mcq
Direction: Choose the correct option

Q1.

What HTTP method is typically used to create a resource in CRUD?
A. POST
B. GET
C. PUT
D. DELETE
Direction: Choose the correct option

Q2.

How do you map a method to handle GET request for a specific user (e.g., /users/5)?
A. @GetMapping('/users/{id}')
B. @PostMapping('/users/{id}')
C. @RequestMapping('/users/{id}') with method=GET
D. Both A and C
Direction: Choose the correct option

Q3.

What annotation binds a URI template variable to a method parameter?
A. @PathVariable
B. @RequestParam
C. @RequestBody
D. @ModelAttribute
Direction: Choose the correct option

Q4.

How do you retrieve all users in a CRUD controller?
A. @GetMapping('/users') returns list
B. @PostMapping('/users') returns list
C. @GetMapping('/user/all')
D. None
Direction: Choose the correct option

Q5.

What annotation binds the request body to a method parameter?
A. @RequestBody
B. @RequestParam
C. @PathVariable
D. @ModelAttribute
Direction: Choose the correct option

Q6.

In a POST request to create a user, what should the method return?
A. ResponseEntity with location header
B. The created user object
C. void
D. Any of the above
Direction: Choose the correct option

Q7.

How do you update a resource using PUT?
A. @PutMapping('/users/{id}') with @RequestBody
B. @PostMapping('/users/{id}')
C. @PatchMapping('/users/{id}')
D. @GetMapping('/users/{id}')
Direction: Choose the correct option

Q8.

What HTTP status code is appropriate for a successful DELETE operation?
A. 204 No Content
B. 200 OK
C. 404 Not Found
D. 500 Internal Error
Direction: Choose the correct option

Q9.

What does @ModelAttribute do in a controller method?
A. Binds form data to a model object and adds it to the model
B. Binds request body
C. Binds path variable
D. Binds request parameter
Direction: Choose the correct option

Q10.

How do you handle exceptions in a CRUD controller?
A. Using @ExceptionHandler
B. Using @ControllerAdvice
C. Using ResponseEntityExceptionHandler
D. All of the above