Test your understanding of essential concepts, annotations, and patterns in Java microservices architecture with these easy, scenario-based questions.
Definition of Microservices
Which statement best describes the microservices architecture in Java-based systems?
- Using only message brokers for service communication.
- Writing services only in the Java programming language.
- Building applications with tight coupling between modules.
- A design in which all parts of an application run in a single, large codebase.
- A style where an application is developed as a collection of small, independently deployable services.
Building Blocks
In a typical Java microservices system, which component handles business rules and operations logic?
- Cache Provider
- Data Loader
- Service Layer
- Config Server
- Servlet Thread
Key Annotations
Which annotation in Java is commonly used to mark a class as a RESTful web service controller?
- @DataController
- @ResourceControler
- @Serivce
- @RestController
- @WebResponser
Communication Methods
What is the main difference between REST and messaging approaches for microservice communication?
- REST can only be used within the same machine.
- REST uses HTTP while messaging uses asynchronous message brokers.
- Messaging is only for error handling.
- REST guarantees delivery but messaging does not.
- Messaging always uses SOAP and REST uses JSON.
Message Broker Examples
Which of the following is an example of a message broker often used in Java microservices for asynchronous communication?
- DataStream
- ActveMQ
- Relation Manager
- WebListener
- ActiveMQ
Security Basics
Which practice helps secure microservices by ensuring only authorized users can access specific endpoints?
- Disabling endpoints
- Applying logging everywhere
- Using only REST instead of messaging
- Enabling auto-scaling
- Implementing authentication and authorization
Service Discovery
What is the primary purpose of a service registry in a microservices architecture?
- To manage database migrations
- To generate API documentation automatically
- To compile Java classes at runtime
- To keep track of available services and their locations
- To store user session data
External Configuration
Why is storing configuration outside of application code important in microservices?
- It increases the performance of database queries.
- It disables error messaging.
- It makes the services use less memory.
- It allows changing settings without recompiling or restarting services.
- It lets logs be written faster.
Resilience and Fault Tolerance
Which mechanism can automatically stop repeated calls to a failing microservice, helping prevent system overload?
- Retry looper
- Circut breaker
- Circuit breaker
- Pooling scheduler
- Hard restarter
Monitoring and Observability
What is the main purpose of monitoring microservices using metrics and logs?
- To store user settings.
- To increase network latency between services.
- To disable health checks.
- To detect and diagnose issues for better performance and reliability.
- To generate random API responses.