Loading

Quipoin Menu

Learn • Practice • Grow

spring / Controller RequestMapping
mcq
Direction: Choose the correct option

Q1.

What is @RequestMapping used for?
A. To map web requests to handler methods
B. To define request parameters
C. To handle exceptions
D. To configure views
Direction: Choose the correct option

Q2.

Which of the following are shortcut annotations for @RequestMapping?
A. @GetMapping
B. @PostMapping
C. @PutMapping
D. All of the above
Direction: Choose the correct option

Q3.

How do you restrict a mapping to a specific HTTP method?
A. @RequestMapping(method = RequestMethod.GET)
B. @GetMapping
C. @PostMapping
D. All of the above
Direction: Choose the correct option

Q4.

What does the headers attribute in @RequestMapping do?
A. Restricts mapping based on request headers
B. Sets response headers
C. Filters headers
D. None
Direction: Choose the correct option

Q5.

What does params attribute in @RequestMapping do?
A. Restricts mapping based on request parameters
B. Defines required parameters
C. Both A and B
D. None
Direction: Choose the correct option

Q6.

How do you map requests that consume a specific content type (e.g., application/json)?
A. consumes = 'application/json'
B. produces = 'application/json'
C. headers = 'Content-Type=application/json'
D. Both A and C
Direction: Choose the correct option

Q7.

How do you map requests that produce a specific content type?
A. produces = 'application/json'
B. consumes = 'application/json'
C. headers = 'Accept=application/json'
D. Both A and C
Direction: Choose the correct option

Q8.

What is the purpose of @RequestMapping on a controller class?
A. To provide a base URL for all methods
B. To define a common header
C. To specify a common consumes type
D. All of the above
Direction: Choose the correct option

Q9.

Can @RequestMapping be used on methods with specific parameters?
A. Yes, using params attribute
B. No
C. Only on class
D. Only on methods
Direction: Choose the correct option

Q10.

What happens if multiple mapping annotations match a request?
A. Spring picks the most specific mapping
B. Ambiguous mapping exception
C. First found is used
D. Random