WGU D287 — JAVA FRAMEWORKS |
COMPREHENSIVE OBJECTIVE ASSESSMENT |
STUDY GUIDE | LATEST UPDATE 2026/2027 |
PRACTICE QUESTIONS AND ANSWERS | EXAM
REVIEW
Table of Contents
1. Spring Core: IoC Container and Dependency Injection
2. Spring Bean Lifecycle and Scopes
3. Spring Boot Fundamentals and Auto-Configuration
4. Spring MVC: Controllers and Request Mapping
5. Building RESTful Web Services
6. Spring Data JPA and Repository Patterns
7. Spring Security: Authentication and Authorization
8. Testing Spring Applications
9. Application Properties and Profiles
10. Spring AOP and Cross-Cutting Concerns
11. Exception Handling in Spring
12. Spring Boot Actuator and Monitoring
, WGU D287 |2
Question 1: What is the primary purpose of the Spring Framework?
A. To replace the Java programming language
B. To simplify enterprise Java development by providing infrastructure support
C. To create mobile applications
D. To manage database schemas only
Correct Answer: B. To simplify enterprise Java development by providing
infrastructure support
The Spring Framework is an application framework that provides comprehensive
infrastructure support for developing Java applications. It handles the plumbing of enterprise
applications so developers can focus on business logic. Spring's core features include
dependency injection, aspect-oriented programming, and transaction management.
Question 2: What is Inversion of Control (IoC) in the context of Spring?
A. A design principle where the framework controls the flow of the program and object
creation
B. A method for reversing strings
C. A type of database transaction
D. A security mechanism
Correct Answer: A. A design principle where the framework controls the flow of the
program and object creation
Inversion of Control is a design principle in which the control of object creation and lifecycle
is transferred from the application code to the framework. Instead of the application creating
objects directly, the Spring IoC container creates and manages them. This promotes loose
coupling and easier testing.
Question 3: What is Dependency Injection in Spring?
A. A technique where objects receive their dependencies from an external source rather than
creating them
B. A method for injecting SQL queries
C. A type of database connection
D. A security vulnerability
Correct Answer: A. A technique where objects receive their dependencies from an
external source rather than creating them
Dependency Injection is a design pattern that implements IoC. Objects declare their
, WGU D287 |3
dependencies, and the Spring container injects them at runtime. This decouples classes from
their dependencies, making code more modular, testable, and maintainable.
Question 4: Which annotation is used to mark a class as a Spring-managed bean?
A. @Bean
B. @Component
C. @Autowired
D. @Configuration
Correct Answer: B. @Component
The @Component annotation is a stereotype annotation that marks a class as a Spring-
managed component. Spring will automatically detect and register it as a bean during
component scanning. @Bean is used in configuration classes to define beans
explicitly, @Autowired is for injection, and @Configuration marks a class as a source of
bean definitions.
Question 5: What is the difference between @Component, @Service, @Repository,
and @Controller?
A. They are identical with no differences
B. They are specialized forms of @Component for different layers of an application
C. They are all deprecated
D. They only work with Spring Boot
Correct Answer: B. They are specialized forms of @Component for different layers of an
application
@Service, @Repository, and @Controller are specializations of @Component. @Service is
used for service layer classes, @Repository for data access classes (and adds exception
translation), and @Controller for web controllers. They provide semantic clarity and enable
specific framework behaviors.
Question 6: What is the purpose of the @Autowired annotation?
A. To automatically inject dependencies into a Spring bean
B. To define a new bean
C. To configure a database connection
D. To create a REST endpoint
, WGU D287 |4
Correct Answer: A. To automatically inject dependencies into a Spring bean
The @Autowired annotation is used for automatic dependency injection. Spring resolves and
injects the required dependency based on type (and optionally by name). It can be applied to
constructors, setters, fields, or methods.
Question 7: Which injection type is recommended for mandatory dependencies in Spring?
A. Field injection
B. Setter injection
C. Constructor injection
D. Method injection
Correct Answer: C. Constructor injection
Constructor injection is recommended for mandatory dependencies because it ensures the
object is created with all required dependencies, supports immutability, and makes testing
easier. Field injection is discouraged because it hides dependencies and makes testing harder.
Setter injection is suitable for optional dependencies.
Question 8: What is the difference between @Bean and @Component?
A. @Bean is used on methods in configuration classes; @Component is used on classes
B. @Bean is used on classes; @Component is used on methods
C. They are identical
D. @Bean is for databases; @Component is for web
Correct Answer: A. @Bean is used on methods in configuration classes; @Component is
used on classes
@Bean is applied to methods within @Configuration classes to explicitly declare a
bean. @Component is applied to classes and is detected through component
scanning. @Bean gives you more control over bean creation, while @Component is more
declarative.
Question 9: What is the default scope of a Spring bean?
A. Prototype
B. Request
C. Singleton
D. Session