Java Spring Autowiring

1. What is the role of the DispatcherServlet in a Spring MVC application?
  • a) Responsible for serving static resources
  • b) Handles HTTP requests and manages the flow of control
  • c) Manages database connections
  • d) Provides dependency injection
2. What is the purpose of the @RequestMapping annotation in a Spring MVC controller?
  • a) To specify the URL path for a controller method
  • b) To define a request parameter
  • c) To configure database connections
  • d) To handle exceptions
3. Which view resolver is commonly used in Spring MVC for resolving views based on logical view names?
  • a) InternalResourceViewResolver
  • b) UrlBasedViewResolver
  • c) XmlViewResolver
  • d) JsonViewResolver
4. In Spring MVC, what is the role of the Model object in a controller method?
  • a) To manage database transactions
  • b) To hold data to be displayed in the view
  • c) To define the database schema
  • d) To handle HTTP requests
5. What is the purpose of the @ModelAttribute annotation in a Spring MVC controller method?
  • a) To define a model class
  • b) To handle form submissions
  • c) To specify the request method
  • d) To configure session attributes
6. What is the primary purpose of the Spring Framework?
  • a) To provide a lightweight container for Java applications
  • b) To create standalone Java applications
  • c) To develop Android applications
  • d) To build web applications with Python
7. Which module of the Spring Framework is responsible for providing dependency injection?
  • a) Spring AOP
  • b) Spring IOC
  • c) Spring MVC
  • d) Spring ORM
8. What does AOP stand for in the context of the Spring Framework?
  • a) Aspect-Oriented Programming
  • b) Application-Oriented Processing
  • c) Advanced Object Programming
  • d) Aspect-Oriented Processing
9. Which annotation is used to declare a bean in the Spring context without specifying its name?
  • a) @Component
  • b) @Bean
  • c) @Service
  • d) @Repository
10. What is the purpose of the @Autowired annotation in Spring?
  • a) To inject dependencies
  • b) To define a bean
  • c) To create a new instance of a class
  • d) To handle exceptions
11. What is Spring Boot?
  • a) A dependency injection framework
  • b) A standalone Java-based development framework
  • c) A web server
  • d) A tool for building production-ready applications quickly
12. Which annotation is used to mark a class as the entry point of a Spring Boot application?
  • a) @SpringBootApplication
  • b) @SpringBootMain
  • c) @MainApplication
  • d) @EntryPoint
13. What is the purpose of the application.properties file in a Spring Boot project?
  • a) To store Java code
  • b) To configure application properties and settings
  • c) To define database schema
  • d) To write unit tests
14. Which embedded server does Spring Boot use by default?
  • a) Tomcat
  • b) Jetty
  • c) Undertow
  • d) Apache HTTP Server
15. What is the purpose of the @RestController annotation in a Spring Boot application?
  • a) To define a controller for MVC applications
  • b) To define a RESTful web service controller
  • c) To configure database connections
  • d) To define a repository class
16. Which dependency is typically included in a Spring Boot project for data access using JPA?
  • a) spring-boot-starter-data-mongodb
  • b) spring-boot-starter-data-jpa
  • c) spring-boot-starter-web
  • d) spring-boot-starter-security
17. What does the @Autowired annotation do in a Spring Boot application?
  • a) Marks a class as a component
  • b) Injects a bean by type
  • c) Defines a primary bean
  • d) Sets the default profile
  • 18. Which annotation is used to define a bean in a Spring Boot application?
    • a) @Component
    • b) @Bean
    • c) @Service
    • d) @Repository
    19. What is the purpose of Spring Boot's Actuator module?
    • a) To create RESTful APIs
    • b) To monitor and manage the application
    • c) To handle security concerns
    • d) To manage database connections
    20. Which of the following commands is used to build and run a Spring Boot application with Maven?
    • a) mvn install
    • b) mvn compile
    • c) mvn spring-boot:run
    • d) mvn package
    Answers:
    • 1. a
    • 2. b
    • 3. a
    • 4. a
    • 5. a
    • 6. b
    • 7. a
    • 8. a
    • 9. b
    • 10. b
    • 11. d
    • 12. a
    • 13. b
    • 14. a
    • 15. b
    • 16. b
    • 17. b
    • 18. b
    • 19. b
    • 20. c

    About the Author



    Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.

    We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc





 PreviousNext