001.
Spring Framework is primarily used for ___________
A. web development only
B. enterprise application development
C. mobile application development
D. database management
Answer: B
002. The core concept of Spring Framework is ___________
A. Inheritance
B. Polymorphism
C. Inversion of Control (IoC)
D. Encapsulation
Answer: C
003. Spring Framework consists of ___________
A. 5 modules
B. 10 modules
C. 15 modules
D. more than 20 modules
Answer: D
004. Java-based configuration in Spring is achieved using ___________
A. XML files
B. @Configuration annotation
C. properties files
D. YAML files
Answer: B
005. Dependency Injection in Spring helps in ___________
A. reducing coupling between classes
B. increasing performance
C. reducing memory usage
D. improving security
Answer: A
006. Constructor Injection in Spring is ___________
A. optional for all dependencies
B. mandatory for required dependencies
C. slower than setter injection
D. not supported in Spring 5
Answer: B
007. Setter Injection in Spring uses ___________
A. constructor parameters
B. setter methods
C. field injection
D. method injection
Answer: B
008. AutoScanning in Spring is enabled using ___________
A. @ComponentScan annotation
B. @Autowired annotation
C. @Component annotation
D. @Service annotation
Answer: A
009. The @Component annotation is used to ___________
A. inject dependencies
B. mark a class as Spring managed bean
C. configure database connection
D. enable transaction management
Answer: B
010. IoC container in Spring is responsible for ___________
A. creating objects only
B. managing object lifecycle only
C. dependency injection only
D. creating objects, managing lifecycle and dependency injection
Answer: D
011. Spring Boot Application is created using ___________
A. @SpringBootApplication annotation
B. @Application annotation
C. @Boot annotation
D. @SpringApp annotation
Answer: A
012. @SpringBootApplication annotation combines ___________
A. @Configuration and @ComponentScan
B. @EnableAutoConfiguration and @ComponentScan
C. @Configuration, @EnableAutoConfiguration and @ComponentScan
D. @Service and @Repository
Answer: C
013. Autowiring in Spring Boot can be done using ___________
A. @Autowired annotation only
B. @Inject annotation only
C. both @Autowired and @Inject annotations
D. @Wire annotation
Answer: C
014. The default scope of a Spring bean is ___________
A. prototype
B. singleton
C. request
D. session
Answer: B
015. Prototype scope in Spring means ___________
A. only one instance per container
B. new instance for each request
C. one instance per session
D. one instance per application
Answer: B
016. Logger in Spring Boot is configured using ___________
A. log4j.properties
B. logback.xml
C. application.properties
D. all of the above
Answer: D
017. AOP stands for ___________
A. Aspect Oriented Programming
B. Application Oriented Programming
C. Abstract Oriented Programming
D. Advanced Object Programming
Answer: A
018. In Spring AOP, a cross-cutting concern is ___________
A. business logic
B. functionality that spans multiple modules
C. database operations
D. user interface logic
Answer: B
019. AOP advice types include ___________
A. @Before and @After only
B. @Around only
C. @Before, @After, @Around, @AfterReturning, @AfterThrowing
D. @During and @Between
Answer: C
020. Spring Boot follows ___________
A. configuration over convention
B. convention over configuration
C. both equally
D. neither approach
Answer: B
021. JDBC API limitations include ___________
A. boilerplate code
B. exception handling complexity
C. resource management issues
D. all of the above
Answer: D
022. Spring Data JPA provides ___________
A. automatic repository implementation
B. query generation from method names
C. pagination and sorting support
D. all of the above
Answer: D
023. To use Spring Data JPA with Spring Boot, the dependency is ___________
A. spring-boot-starter-data-jpa
B. spring-boot-starter-jpa
C. spring-data-jpa
D. hibernate-core
Answer: A
024. JPA configuration in Spring Boot is done in ___________
A. persistence.xml
B. application.properties
C. hibernate.cfg.xml
D. jpa.properties
Answer: B
025. Pagination in Spring Data JPA is achieved using ___________
A. Pageable interface
B. Page interface
C. Sort interface
D. both Pageable and Page interfaces
Answer: D
026. The findAll(Pageable pageable) method returns ___________
A. List<Entity>
B. Page<Entity>
C. Set<Entity>
D. Collection<Entity>
Answer: B
027. Query creation in Spring Data JPA can be done by ___________
A. method name derivation
B. @Query annotation
C. named queries
D. all of the above
Answer: D
028. @Query annotation is used for ___________
A. custom JPQL queries
B. native SQL queries
C. both JPQL and native SQL queries
D. HQL queries only
Answer: C
029. Named queries in JPA are defined using ___________
A. @NamedQuery annotation
B. @Query annotation
C. XML configuration
D. both @NamedQuery annotation and XML configuration
Answer: D
030. Spring Transaction management provides ___________
A. programmatic transaction management
B. declarative transaction management
C. both programmatic and declarative
D. automatic transaction management only
Answer: C
031. @Transactional annotation can be applied at ___________
A. method level only
B. class level only
C. both method and class level
D. field level only
Answer: C
032. The default transaction propagation in Spring is ___________
A. REQUIRED
B. SUPPORTS
C. MANDATORY
D. NEVER
Answer: A
033. Update operations in Spring Data JPA require ___________
A. @Modifying annotation
B. @Transactional annotation
C. both @Modifying and @Transactional
D. @Update annotation
Answer: C
034. Custom repository implementation in Spring Data JPA is done by ___________
A. extending JpaRepository
B. creating custom interface and implementation
C. using @Repository annotation
D. implementing CrudRepository
Answer: B
035. JpaRepository extends ___________
A. Repository interface
B. CrudRepository interface
C. PagingAndSortingRepository interface
D. ListCrudRepository interface
Answer: C
036. The @Entity annotation is used to ___________
A. mark a class as JPA entity
B. create database table
C. define primary key
D. establish relationships
Answer: A
037. @Id annotation in JPA is used to ___________
A. mark primary key field
B. generate unique values
C. create index
D. define foreign key
Answer: A
038. Lazy loading in JPA means ___________
A. data is loaded immediately
B. data is loaded on demand
C. data is never loaded
D. data is cached permanently
Answer: B
039. @OneToMany relationship in JPA represents ___________
A. one entity related to many entities
B. many entities related to one entity
C. one-to-one relationship
D. many-to-many relationship
Answer: A
040. Best practice for Spring Data JPA includes ___________
A. using appropriate fetch strategies
B. proper transaction boundaries
C. avoiding N+1 query problem
D. all of the above
Answer: D
Q#1. What is a microservice?
A) A small application that runs on a single machine
B) A design pattern used in monolithic applications
C) An architectural style that structures an application as a collection of loosely coupled services
D) A cloud-based service for micro-managing resources
Answer: C
Q#2. Which of the following is NOT a characteristic of microservices?
A) Small and focused on a single responsibility
B) Centralized database for all services
C) Independent deployability
D) Inter-Service Communication
Answer: B
Q#3. What is one of the primary roles of Spring Boot in microservices development?
A) To provide a large monolithic application framework.
B) To enforce a specific technology stack for all microservices.
C) To manage database transactions across all services.
D) To simplify the configuration and deployment of microservices.
Answer: D
Q#4. How does an API Gateway contribute to security in a microservices architecture?
A) By embedding security code within each microservice.
B) By managing authentication and authorization for incoming requests.
C) By storing and managing user data directly.
D) By eliminating the need for secure communication protocols.
Answer: B
Q#5. How does a Service Registry assist communication in a microservices architecture?
A) By hardcoding the addresses of each service into the client.
B) By providing a central directory where services can register and discover each other
dynamically.
C) By directly managing the communication protocols between services.
D) By storing and managing user session data.
Answer: B
Q#6. In a Spring Boot microservices architecture, which of the following tools can be used
as an alternative to Netflix Eureka for service discovery?
A) Spring Data JPA
B) Spring Cloud Config
C) Consul
D) RabbitMQ
Answer: C
Q#7. What is the primary purpose of an API Gateway in microservices?
A) To directly manage databases for all microservices.
B) To act as a single entry point for client requests to multiple microservices.
C) To enforce security policies within each microservice.
D) To replace the need for inter-service communication.
Answer: B
Q#8. What makes HTTP/HTTPS a suitable protocol for microservices communication?
A) Its ability to transfer large files quickly
B) Its native support for real-time communication
C) Its widespread use and support for RESTful APIs
D) Its built-in messaging queue capabilities
Answer: C
Q#9. In microservices architecture, what is meant by ‘polyglot persistence’?
A) Using multiple databases within a single service
B) Using the same database technology across all services
C) Using different database technologies for different services based on their needs
D) Using multiple programming languages within a single service
Answer: C
Q#10. What is Circuit Breaker pattern used for in microservices?
A) To manage database transactions
B) To handle failed requests between microservices gracefully
C) To increase service discovery efficiency
D) To ensure data consistency across services
Answer: B
Q#11. Which principle states that each microservice should have its own database?
A) Single Responsibility Principle
B) Database Isolation Principle
C) Decentralized Data Management
D) Data Consistency Principle
Answer: C
Q#12. What is a common way to handle inter-service communication in a microservices
architecture?
A) Monolithic APIs
B) SOAP web services
C) RESTful APIs
D) Batch processing
Answer: C
Q#13. What is the main advantage of using Docker with microservices?
A) Enhanced performance
B) Simplified scaling and deployment
C) Increased security
D) Easier coding
Answer: B
Q#14. Which tool can be used for monitoring and managing microservices?
A) JUnit
B) Jenkins
C) Prometheus
D) Maven
Answer: C
Q#15. What does the term ‘event-driven architecture’ refer to in microservices?
A) Using API calls to manage service dependencies
B) Using scheduled tasks to manage microservices
C) Using database triggers to handle updates
D) Using events to trigger changes in the system
Answer: D
Q#16. Which of the following is a benefit of using Spring Cloud Config for microservices?
A) Centralized configuration management
B) Enhanced database transaction handling
C) Improved user interface design
D) Faster development cycles
Answer: A
Q#17. What is the purpose of ‘Hystrix’ in a Spring Boot microservices application?
A) To manage database connections
B) To provide service discovery
C) To implement the Circuit Breaker pattern
D) To handle authentication
Answer: C
Q#18. Which design pattern is commonly used to manage the lifecycle of microservices?
A) Singleton Pattern
B) Factory Pattern
C) Observer Pattern
D) Orchestration Pattern
Answer: D
Q#19. What is the role of Spring Cloud Sleuth & Zipkin in microservices?
A) To provide security for microservices
B) To handle database transactions
C) To enable distributed tracing and logging
D) To manage service deployment
Answer: C
Q#20. What is the primary purpose of using Spring Boot Actuator in microservices?
A) To enhance security
B) To provide production-ready features like monitoring and health checks
C) To improve database performance
D) To simplify user authentication
Answer: B
Q#21. What annotation is used to enable Eureka client functionality?
A) @EnableEurekaClient
B) @EnableDiscoveryClient
C) @EnableFeignClients
D) @EnableConfigServer
Answer: A
Q#22. In the context of Spring Cloud Config, what is the purpose of the
@EnableConfigServer annotation?
A) To enable Eureka client functionality
B) To enable Spring Cloud Config Server functionality
C) To enable distributed tracing
D) To enable API Gateway functionality
Answer: B
Q#23. What does the code snippet demonstrate in a Spring Boot microservices application?
A) Synchronous communication between services using RestTemplate
B) Asynchronous communication between services using RestTemplate
C) Inter-service communication using message queues
D) Database access using JPA
Answer: A
Q#24. What is the purpose of the given application.properties configuration?
A) To configure the database connection and API endpoints
B) To set up application logging and error handling
C) To enable the application to register with Eureka for service discovery
D) To define security settings and authentication protocols
Answer: C
Q#25. What does the configuration class do?
A) Configures a database connection
B) Enables Eureka client functionality
C) Configures an API Gateway using Zuul
D) Sets up distributed tracing
Answer: C
Q#26. What is the purpose of the @FeignClient annotation in a Spring Boot application?
A) To enable Eureka client functionality
B) To declare a REST client that uses Feign
C) To enable distributed tracing
D) To configure a database connection
Answer: B
Q#27. Given the Feign client interface, what does it do?
A) Defines a REST client for interacting with Service B
B) Configures a database connection for Service B
C) Sets up distributed tracing for Service B
D) Enables service registration for Service B
Answer: A
Q#28. Which of the following features is a key benefit of using Spring Cloud Gateway?
A) Decentralized configuration management
B) Integrated development environment
C) Dynamic routing and load balancing
D) Built-in messaging queue
Answer: C
Q#29. Which design pattern is commonly used for handling data consistency in
microservices?
A) Singleton Pattern
B) Saga Pattern
C) Factory Pattern
D) Proxy Pattern
Answer: B
Q#30. What does the configuration class demonstrate?
A) Configuration of a data source
B) Creation of a RestTemplate bean for inter-service communication
C) Configuration of an API Gateway
D) Setup of a distributed tracing tool
Answer: B
Q#31. Which of the following tools can be used for container orchestration in a
microservices architecture?
A) Docker Compose
B) Kubernetes
C) JUnit
D) Maven
Answer: B
Q#32. What is the purpose of the @LoadBalanced annotation in Spring Boot?
A) To enable distributed tracing
B) To configure a RestTemplate bean for client-side load balancing
C) To manage database transactions
D) To set up an API Gateway
Answer: B
Q#33. In Spring Cloud, what is the purpose of using a Config Server?
A) To handle user authentication
B) To manage database connections
C) To provide externalized configuration for microservices
D) To monitor application performance
Answer: C
Q#34. Which of the following best describes the purpose of the Sidecar Pattern in
microservices?
A) To enhance user interface design
B) To manage database connections
C) To offload common functionalities like logging and monitoring from the main service
D) To handle distributed transactions
Answer: C
Q#35. What is the benefit of using Docker in a microservices architecture?
A) Simplified user interface design
B) Enhanced security
C) Consistent deployment environments
D) Improved data consistency
Answer: C
Q#36. What does the instruction in Dockerfile do?
A) It sets the main class for the Java application.
B) It adds the application JAR file from the ‘target’ directory on the host to the container and
renames it to ‘myapp.jar’.
C) It sets environment variables for the Docker container.
D) It installs dependencies required by the Java application.
Answer: B
Q#37. Which tools can be used for monitoring and visualizing metrics in Spring Boot
microservices?
A) Jenkins
B) Prometheus and Grafana
C) JUnit
D) Hibernate
Answer: B
Q#38. Which of the following is NOT a typical function of an API Gateway?
A) Load balancing
B) Service discovery
C) Centralized logging and monitoring
D) Direct database access for all microservices
Answer: D
Q#39. Which of the following is NOT a role of a Service Registry?
A) Ensuring high availability of service instances through health checks.
B) Storing business logic for individual services.
C) Enabling load balancing by providing service instance details to clients.
D) Allowing services to dynamically discover and communicate with each other.
Answer: B
Q#40. Which tool is commonly used for service registration and discovery in Spring Boot
microservices?
A) Apache Kafka
B) Netflix Eureka
C) Jenkins
D) Prometheus
Answer: B
Q#41. What is the primary purpose of Netflix Eureka in Spring Boot microservices?
A) To provide logging and monitoring services
B) To manage build and deployment pipelines
C) To register and discover services dynamically
D) To handle message queuing and processing
Answer: C
Q#42. What is the primary purpose of using Resilience4j in a microservices architecture?
A) To enable centralized and version-controlled configuration updates
B) To provide resilience and fault-tolerance mechanisms for microservices
C) To trace and monitor requests across multiple services
D) To register microservices with Eureka server
Answer: B
Q#43. Which of the following features is NOT provided by Resilience4j?
A) Circuit Breaker
B) Rate Limiter
C) Retry
D) Data Encryption
Answer: D
Q#44. Besides HTTP/HTTPS, which other protocol is commonly used for microservices
communication?
A) SOAP
B) FTP
C) gRPC
D) IMAP
Answer: C
Q#45. How does Spring Cloud Config enhance the deployment process?
A) By providing automated UI design tools
B) By enabling centralized and version-controlled configuration updates
C) By offering built-in analytics and reporting
D) By embedding a web server within each microservice
Answer: B
Q#46. What is the primary role of Spring Cloud Gateway in microservices?
A) To provide a single entry point for client requests and route them to the appropriate services
B) To handle database connections
C) To manage user authentication
D) To perform background processing tasks
Answer: A
Q#47. In a microservices architecture, what is the benefit of using a distributed tracing tool
like Zipkin?
A) To improve database performance
B) To enhance user interface design
C) To trace and monitor requests across multiple services
D) To manage user authentication
Answer: C
Q1. What does API stand for?
A. Application Programming Interface
B. Application Program Interaction
C. Applied Program Interface
D. Application Process Integration
✅ Answer: A
Q2. Which protocol is most commonly used for web APIs?
A. FTP
B. SMTP
C. HTTP/HTTPS
D. SSH
✅ Answer: C
Q3. Microservices architecture is mainly based on?
A. Monolithic applications
B. Distributed services
C. Single database design
D. Centralized deployment
✅ Answer: B
Q4. Which of the following is a key benefit of microservices?
A. Tight coupling
B. High scalability
C. Single point of failure
D. Centralized control
✅ Answer: B
Q5. REST APIs primarily use which data format?
A. XML
B. JSON
C. CSV
D. DOCX
✅ Answer: B
Q6. In microservices, each service should be?
A. Tightly coupled
B. Independent and loosely coupled
C. Dependent on central DB
D. Controlled by one server
✅ Answer: B
Q7. Which of these is a disadvantage of microservices?
A. Easy deployment
B. Increased complexity in communication
C. Better fault isolation
D. Independent scaling
✅ Answer: B
Q8. Which HTTP method is idempotent?
A. POST
B. PUT
C. PATCH
D. DELETE
✅ Answer: B
Q9. In REST API, which status code means "Resource Not Found"?
A. 200
B. 201
C. 404
D. 500
✅ Answer: C
Q10. Which tool is widely used for API testing?
A. GitHub
B. Postman
C. Jenkins
D. Docker
✅ Answer: B
Q11. Which is an example of an API gateway?
A. Amazon API Gateway
B. Docker
C. GitLab
D. MySQL
✅ Answer: A
Q12. Microservices communication is often done via?
A. Shared memory
B. Message queues / HTTP
C. File systems
D. SSH
✅ Answer: B
Q13. Which pattern helps in managing multiple microservices communication?
A. Singleton
B. API Gateway
C. Adapter
D. Proxy only
✅ Answer: B
Q14. In REST, which HTTP code indicates "Created"?
A. 200
B. 201
C. 202
D. 204
✅ Answer: B
Q15. Which of the following is a synchronous communication method?
A. Message Queue
B. Event Streaming
C. HTTP Request/Response
D. Kafka
✅ Answer: C
Q16. Which is a popular event streaming platform used with microservices?
A. MongoDB
B. Apache Kafka
C. MySQL
D. Redis only
✅ Answer: B
Q17. The database pattern "Database per Service" in microservices means?
A. All services share one DB
B. Each service has its own DB
C. Services use file systems
D. DB is optional
✅ Answer: B
Q18. Which of these is an API style?
A. REST
B. SOAP
C. GraphQL
D. All of the above
✅ Answer: D
Q19. SOAP APIs usually use which format?
A. JSON
B. XML
C. CSV
D. YAML
✅ Answer: B
Q20. Which HTTP method is used to fetch data?
A. POST
B. GET
C. PUT
D. DELETE
✅ Answer: B
Q21. Which is NOT a benefit of APIs?
A. Reusability
B. Integration
C. Isolation from systems
D. Manual dependency
✅ Answer: D
Q22. A microservice should be designed around?
A. Database schema
B. Business capabilities
C. Code structure only
D. Server configuration
✅ Answer: B
Q23. Which API style allows fetching only required fields?
A. REST
B. SOAP
C. GraphQL
D. OData only
✅ Answer: C
Q24. Which microservice deployment strategy avoids downtime?
A. Big bang
B. Blue-Green deployment
C. Single server only
D. Manual copy
✅ Answer: B
Q25. Which is NOT a type of API?
A. Open API
B. Partner API
C. Private API
D. Static API
✅ Answer: D
Q26. Which tool helps with microservices containerization?
A. Docker
B. Jenkins
C. Postman
D. GitHub
✅ Answer: A
Q27. Which is used for container orchestration in microservices?
A. Git
B. Kubernetes
C. Postman
D. REST
✅ Answer: B
Q28. Which of these is NOT an API authentication method?
A. OAuth
B. JWT
C. API Keys
D. BIOS password
✅ Answer: D
Q29. Which HTTP code indicates "Internal Server Error"?
A. 200
B. 400
C. 401
D. 500
✅ Answer: D
Q30. Which microservice principle is followed for resilience?
A. Circuit Breaker Pattern
B. Proxy Pattern
C. Singleton Pattern
D. Strategy Pattern
✅ Answer: A
Q31. Which of these is a lightweight messaging protocol for IoT APIs?
A. HTTP
B. FTP
C. MQTT
D. SMTP
✅ Answer: C
Q32. In API design, versioning is important because?
A. It increases speed
B. It ensures backward compatibility
C. It reduces endpoints
D. It avoids testing
✅ Answer: B
Q33. Which architecture style is used by gRPC?
A. REST
B. RPC (Remote Procedure Call)
C. SOAP
D. GraphQL
✅ Answer: B
Q34. Which database is commonly used with microservices?
A. Only SQL
B. Only NoSQL
C. Both SQL and NoSQL
D. None
✅ Answer: C
Q35. Which HTTP method is generally used to delete resources?
A. PUT
B. POST
C. DELETE
D. GET
✅ Answer: C
Q36. In API security, JWT stands for?
A. Java Web Token
B. JSON Web Token
C. Java Wide Transfer
D. Joint Web Technique
✅ Answer: B
Q37. Which HTTP code means "Unauthorized"?
A. 401
B. 403
C. 404
D. 200
✅ Answer: A
Q38. Which microservice testing type ensures services work together?
A. Unit Testing
B. Integration Testing
C. Load Testing
D. Smoke Testing
✅ Answer: B
Q39. Which of these is an API documentation tool?
A. Postman
B. Swagger (OpenAPI)
C. Docker
D. Redis
✅ Answer: B
Q40. Which microservice pattern handles failure gracefully?
A. Retry
B. Circuit Breaker
C. Fallback
D. All of the above
✅ Answer: D
Q41. Which company introduced Kubernetes?
A. Microsoft
B. Google
C. Amazon
D. IBM
✅ Answer: B
Q42. Which is NOT a REST constraint?
A. Client-Server
B. Stateless
C. Layered System
D. Tight coupling
✅ Answer: D
Q43. Which of these is a message broker for microservices?
A. RabbitMQ
B. Redis
C. Kafka
D. All of the above
✅ Answer: D
Q44. Which HTTP method is safe (no modification)?
A. GET
B. PUT
C. DELETE
D. POST
✅ Answer: A
Q45. Which is NOT a feature of microservices?
A. Decentralized governance
B. Independent deployment
C. Shared database schema
D. Resilience
✅ Answer: C
Q46. Which is used for service discovery in microservices?
A. Eureka
B. Jenkins
C. Postman
D. GitHub
✅ Answer: A
Q47. Which design principle should APIs follow?
A. High coupling
B. Simplicity & Consistency
C. Complex URLs
D. One large service
✅ Answer: B