Loading

Quipoin Menu

Learn • Practice • Grow

spring / Multiple Controllers
mcq
Direction: Choose the correct option

Q1.

Can Spring MVC have multiple controllers?
A. Yes, each controller handles different request mappings
B. No, only one controller allowed
C. Only in Spring Boot
D. Only with XML config
Direction: Choose the correct option

Q2.

How do you define multiple controllers in Spring MVC?
A. Create multiple classes annotated with @Controller
B. Create one class with multiple methods
C. Use @RequestMapping on classes and methods
D. All of the above
Direction: Choose the correct option

Q3.

What is the purpose of @RequestMapping at class level?
A. To define a base URL for all methods in the controller
B. To specify HTTP method
C. To define request parameters
D. None
Direction: Choose the correct option

Q4.

Given @RequestMapping('/user') on class and @RequestMapping('/profile') on method, what URL will handle?
A. /user/profile
B. /profile/user
C. /user
D. /profile
Direction: Choose the correct option

Q5.

How do you organize controllers for different resources?
A. UserController, ProductController, etc.
B. One controller with all mappings
C. Both are fine
D. None
Direction: Choose the correct option

Q6.

Can two controllers have the same request mapping path?
A. No, it would cause ambiguity
B. Yes, if methods differ
C. Yes, with different HTTP methods
D. Both B and C
Direction: Choose the correct option

Q7.

What annotation can be used to specialize a controller for REST APIs?
A. @RestController
B. @Controller
C. @Component
D. @Service
Direction: Choose the correct option

Q8.

How do you inject dependencies into controllers?
A. Using @Autowired
B. Using constructor injection
C. Both A and B
D. None
Direction: Choose the correct option

Q9.

What is the scope of a Spring MVC controller by default?
A. Singleton
B. Prototype
C. Request
D. Session
Direction: Choose the correct option

Q10.

How can you have state in a controller safely?
A. Avoid instance variables; use request-scoped beans or method parameters
B. Use synchronized blocks
C. Use thread-local
D. None