This post contains a few useful Spring Framework (MCQ) multiple-choice questions (quiz) to self-test your knowledge of the Spring Boot framework.
Learn Spring Framework: Master Spring Framework
Check out 100+ quiz questions: 100+ Quiz Questions to Test Your Java, Spring Boot, Microservices, Hibernate, REST API Skills
The answers to each question have been given at the end of this post.
1. What is the main purpose of the Spring Framework?
- To provide a comprehensive programming and configuration model for Java-based enterprise applications
- To provide a comprehensive programming and configuration model for JavaScript-based web applications
- To provide a comprehensive programming and configuration model for PHP-based web applications
- To provide a comprehensive programming and configuration model for Python-based web applications
Answer:
1. To provide a comprehensive programming and configuration model for Java-based enterprise applications
2. What is the default scope of the Spring Bean?
- singleton
- prototype
- request
- session
Answer:
1. singleton
3. Different ways to configure Spring-based applications?
- XML based configuration
- Java-based configuration
- Annotation based configuration
- All of the above
Answer:
4. All of the above
4. What is the purpose of the Spring IoC container?
- To manage the lifecycle of beans and their dependencies
- To handle the configuration of the application
- To provide a caching mechanism for the application
- To provide a security mechanism for the application
Answer:
1. To manage the lifecycle of beans and their dependencies
5. What is the purpose of the Spring MVC module?
- To provide a web framework for building web applications
- To provide a data access framework for accessing databases
- To provide a caching framework for caching data
- To provide a security framework for securing web applications
Answer:
1. To provide a web framework for building web applications
6. What are Spring stereotype annotations?
- @Service
- @Controller
- @Repository
- @Component
- All of the above
Answer:
5. All of the above
7. What are two ways to achieve dependency Injection in Spring?
- Using Getter and Setter methods
- Using Setter and Constructor
- Using Getter and Constructor
- Using Setter and Factory methods
Answer:
2. Using Setter and Constructor
8. What is the scope to create a new instance every time the bean is requested from the spring container?
- singleton
- prototype
- request
- session
Answer:
2. prototype
9. What is the purpose of the Spring MVC module?
- To provide a web framework for building web applications
- To provide a data access framework for accessing databases
- To provide a caching framework for caching data
- To provide a security framework for securing web applications
Answer:
1. To provide a web framework for building web applications
10. Which is the front controller in Spring MVC?
- DispatcherServlet
- FrontDispatcherServlet
- FrontControllerService
- None of the above
Answer:
1. DispatcherServlet
11. Spring MVC Framework is designed based on which Design Pattern?
Answer:
1. Model-View-Controller (MVC)
12. In spring MVC, DispatcherServlet consults ____________ to map the logical view name with the actual view implementation
- ViewResolver
- Handler Mapper
- Controller
- Model
Answer:
1. ViewResolver
13. In Spring MVC web applications, all the HTTP requests first come to which component?
- DispatcherServlet
- Controller
- HandlerMapper
- None of the above
Answer:
1. DispatcherServlet
14. What is the purpose of the Spring JDBC module?
- To provide a data access framework for accessing databases
- To provide a web framework for building web applications
- To provide aspect-oriented programming functionality
- To provide caching functionality
Answer:
1. To provide a data access framework for accessing databases
15. Which Spring Framework module is used to implement cross-cutting concerns in Spring based-applications?
- ORM
- AOP
- JDBC
- TXM
Answer:
2. AOP
16. JdbcTemplate implements the below design pattern?
- Strategy design pattern
- Template Design pattern
- Singleton design pattern
- Decorator design pattern
Answer:
2. Template Design pattern
17. Different ways to inject Spring beans in Spring-based applications?
- Constructor based
- Setter based
- Field-based
- All of the above
Answer:
4. All of the above
18. Are singleton beans thread-safe?
- Yes
- No
Answer:
2. No
19. Which Spring annotation is used to create RESTful web services using Spring MVC?
- @RestController
- @Controller
- @Component
- @Rest
Answer:
1. @RestController
20. @RestController annotation is a combination of the below two annotations
- @Component and @ResponseBody annotations
- @Controller and @ResponseBody annotations
- @Service and @ResponseBody annotations
- None of the above
Answer:
2. @Controller and @ResponseBody annotations
21. Which Spring annotation is used to handle HTTP POST requests?
- @GetMapping
- @PutMapping
- @CreateMapping
- @PostMapping
Answer:
4. @PostMapping
22. Which Spring annotation is used to handle HTTP GET requests?
- @GetMapping
- @PutMapping
- @CreateMapping
- @PostMapping
Answer:
1. @GetMapping
23. Which Spring annotation is used to handle HTTP DELETE requests?
- @GetMapping
- @PutMapping
- @DeleteMapping
- @PostMapping
Answer:
@DeleteMapping
24. Which Spring annotation is used to handle HTTP PUT requests?
- @GetMapping
- @PutMapping
- @DeleteMapping
- @PostMapping
Answer:
2. @PutMapping
25. Which annotation do we use to mark the class as a Service class/component?
- @Component
- @Service
- @Controller
- @Repository
Answer:
2. @Service
26. What is the primary use of the Spring Security module?
- To provide authentication and authorization for web applications
- To provide data access and management
- To provide Model-View-Controller architecture
- To provide aspect-oriented programming functionality
Answer:
1. To provide authentication and authorization for web applications
27. Which Spring annotation is used to inject the Spring bean?
- @Bean
- @Autowired
- @Service
- @Inject
Answer:
2. @Autowired
28. Which Spring annotation is used to extract the URI template variable value?
- @PathVariable
- @ParamRequest
- @ModelAttribute
- @RequestMapping
Answer:
1. @PathVariable
29. Which interface represents the Spring IOC container?
- ApplicationContent
- ApplicationContentFactory
- SessionFactory
- DispatchServlet
Answer:
1. ApplicationContext
Spring Boot Quiz
There is a separate quiz for Spring Boot: Spring Boot Quiz - MCQ - Multiple Choice Questions
Related Posts
- Java String Quiz
- Java Arrays Quiz
- Java Loops Quiz
- Java OOPS Quiz
- Java OOPS Quiz - Part 1
- Java OOPS Quiz - Part 2
- Java Exception Handling Quiz
- Java Collections Quiz
- Java Generics Quiz
- Java Multithreading Quiz
- JDBC Quiz
- Java Lambda Expressions Quiz
- Java Functional Interfaces Quiz
- Java Streams API Quiz
- Java Date Time Quiz
- Java 8 Quiz
- JSP Quiz - MCQ - Multiple Choice Questions
- Servlet Quiz - MCQ - Multiple Choice Questions
- Hibernate Quiz - MCQ - Multiple Choice Questions
- JPA Quiz - MCQ - Multiple Choice Questions
- Java I/O Quiz - MCQ - Multiple Choice Questions
- Java NIO Quiz - MCQ - Multiple Choice Questions
- Java Swing - MCQ - Multiple Choice Questions
- Java Regex Quiz - MCQ - Multiple Choice Questions
- Java Operators - MCQ - Multiple Choice Questions
- Java Data Types Quiz - MCQ - Multiple Choice Questions
Comments
Post a Comment
Leave Comment