preface

Recently in view of the Internet company interview asked knowledge points, summed up the Java programmer interview involves most of the interview questions and answers to share with you, I hope to help you review before the interview and find a good job, but also save you on the Internet to search for information time to learn.

Content covers: Java, MyBatis, ZooKeeper, Dubbo, Elasticsearch, Memcached, Redis, MySQL, Spring, SpringBoot, SpringCloud, RabbitMQ, Kafka, Linux and other technology stacks.

Full version Java interview questions address: Java backend questions integration

1. What do you know about microservices?

Microservices, also known as microservices architecture, is an architectural style that builds applications as small, autonomous collections of services modeled on business domains.

In layman’s terms, you have to see how bees build their honeycomb by aligning hexagonal wax cells.

They started with small pieces of various materials and went on to build a large beehive from them.

These cells form patterns that produce sturdy structures that hold specific parts of the hive together.

Here, each cell is independent of the other, but it’s also related to other cells.

This means that damage to one cell does not damage other cells, so the bees can rebuild those cells without affecting the entire hive.

Figure 1: Cellular representation of microservices – refer to the figure above for microservice interview questions.

Here, each hexagon shape represents a separate service component. Similar to the work of bees, each agile team builds individual service components using available frameworks and technology stacks of their choice.

Like in a beehive, each service component forms a powerful microservice architecture to provide better scalability.

In addition, agile teams can address each service component individually with little or minimal impact on the overall application.

2. What are the advantages of microservices architecture?

Figure 2: Advantages of microservices – microservices interview questions

· Independent development – All microservices can be easily developed according to their respective functions

· Standalone deployment — They can be deployed independently in any application based on their services

· Fault isolation – The system can continue to run even if one of the application’s services fails

· Hybrid technology stack — Different languages and technologies can be used to build different services for the same application

· Granular scaling — Individual components can be scaled as needed without all components being scaled together

3. What are the characteristics of micro-services?

Figure 3: Characteristics of microservices – microservices interview questions

· Decoupling — Services within the system are largely separated. As a result, the entire application can be easily built, changed, and extended

· Componentization — Microservices are treated as standalone components that can be easily replaced and upgraded

· Business capabilities — Microservices are very simple and focus on a single function

· Autonomy — Developers and teams can work independently of each other to increase speed

· Continuous delivery — through system automation of software creation, testing, and approval, allowing frequent software releases

· Responsibility — Microservices does not focus on the application as a project. Instead, they see applications as products they are responsible for

· Decentralized governance — Focus on using the right tools to do the right job. This means that there are no standardization patterns or any technical patterns. Developers are free to choose the most useful tools to solve their problems

· Agile — Microservices support agile development. Any new features can be quickly developed and discarded again

4. What are the best practices for designing microservices?

Here are some best practices for designing microservices:

Figure 4: Best practices for designing microservices – microservices interview questions

5. How does the microservices architecture work?

Microservices architecture has the following components:

Figure 5: Microservices architecture – Microservices interview questions

· Clients — Different users from different devices send requests.

· Identity provider — Authenticates user or customer identity and issues security tokens.

· API Gateway — Handles client requests.

· Static content — Holds all the content of the system.

· Management – Balancing services on nodes and identifying failures.

· Service discovery — A guide for finding communication paths between microservices.

· Content delivery network — a distributed network of proxy servers and their data centers.

· Remote services – Enable remote access information that resides on the NETWORK of IT devices.

6. What are the advantages and disadvantages of microservices architecture?

7. What are the differences between monolithic, SOA and microservice architectures?

Figure 6: Comparison between monolithic SOA and microservices – microservices interview question

· A monolithic architecture is similar to a large container in which all the software components of an application are assembled together and tightly packaged.

A service-oriented architecture is a collection of services that communicate with each other.

Communication can involve simple data transfer or two or more services that coordinate some activities.

Microservices architecture is an architectural style that builds applications as small, autonomous collections of services modeled on business domains.

8. What challenges do you face when using microservices architecture?

Developing smaller microservices sounds easy enough, but the challenges often encountered in developing them are as follows.

Automation components: It is difficult to automate because there are many smaller components.

Therefore, for each component, we must follow the Build, Deploy, and Monitor phases.

Susceptibility: Maintaining large numbers of components together makes it difficult to deploy, maintain, monitor, and identify problems.

It requires good awareness around all the components.

Configuration management: Sometimes it becomes difficult to maintain the configuration of components in a variety of environments.

Debug:

It’s hard to find every service that’s wrong.

Maintaining centralized logging and dashboards to debug problems is critical.

9. What are the key differences between SOA and microservices architectures?

The key differences between SOA and microservices are as follows:

10. What are the characteristics of micro services?

You can list the characteristics of microservices, as follows:

Figure 7: Characteristics of microservices – microservices interview questions

What is Domain-driven design?

Figure 8: DDD principles – Microservices interview questions

12. Why domain Driven Design (DDD)?

Figure 9: We need DDD factors – micro service interview questions

13. What is the ubiquitous language?

If you must define a generic language (UL), it is a common language used by developers and users of a particular domain through which the domain can be easily interpreted.

The ubiquitous language must be very clear so that it puts all team members on the same page and translates in a way that machines can understand.

What is cohesion?

The degree to which elements within a module belong is known as cohesion.

15. What is coupling?

A measure of the strength of dependencies between components is known as coupling. A good design is always considered to have high cohesion and low coupling.

What is REST/RESTful and what is its purpose?

Representational State Transfer (REST)/RESTful Web services are an architectural style that helps computer systems communicate over the Internet.

This makes microservices easier to understand and implement.

Microservices can be implemented with or without RESTful apis, but it is always easier to build loosely coupled microservices using RESTful apis.

17. What do you know about Spring Boot?

In fact, as new features are added, springs become more and more complex.

If you must start a new Spring project, you must add a build path or add maven dependencies, configure the application server, and add spring configuration.

So everything had to start from scratch.

Spring Boot is the solution to this problem.

With Spring Boot, you can avoid all boilerplate code and configuration.

So, basically think of yourself as if you’re baking a cake, and spring is like the ingredients you need to make a cake, and spring boots are the complete cake in your hand.

Figure 10: Spring Boot factors – microservices interview questions

What is a Spring-booted executor?

Spring Boot executors provide restful Web services to access the current state of running applications in a production environment.

With the help of actuators, you can examine various metrics and monitor your application.

19. What is Spring Cloud?

According to Spring Cloud’s official website, Spring Cloud provides developers with tools to quickly build common patterns in distributed systems (such as configuration management, service discovery, circuit breakers, intelligent routing, leadership elections, distributed sessions, and cluster state).

20. What problems does Spring Cloud solve?

Few of the problems we face when developing distributed microservices using Spring Boot are solved by Spring Cloud.

· Complexity associated with distributed systems — including network issues, delay overhead, bandwidth issues, security issues.

· Ability to handle service discovery – Service discovery allows processes and services in a cluster to find and communicate with each other.

· Solve redundancy problems — Redundancy problems often occur in distributed systems.

· Load balancing — Improves workload distribution across multiple computing resources (such as clusters of computers, network links, central processing units).

· Reduce performance issues — Reduce performance issues due to various operational overhead.

21. What is the use of WebMvcTest annotations in Spring MVC applications?

The WebMvcTest annotation is used to unit test the Spring MVC application in cases where the test target is focused only on Spring MVC components.

In the snapshot shown above, we just want ToTestController to start.

When this unit test is executed, all other controllers and mappings are not started.

22. Can you give me some key points about breaks and microservices?

While you can implement microservices in many ways, REST over HTTP is one way to implement microservices.

REST can also be used for other applications, such as Web applications, API designs, and MVC applications, to provide business data.

Microservices are an architecture in which all components of a system are placed into separate components that can be built, deployed, and extended separately.

There are certain principles and best practices of microservices that help build resilient applications.

In short, you can say THAT REST is a medium for building microservices.

23. What are the different types of microservice testing?

When using microservices, testing is complicated by having multiple microservices working together. Therefore, tests are divided into different levels.

At the bottom, we have technology-oriented testing, such as unit testing and performance testing. These are fully automated.

At the intermediate level, we did exploratory testing such as stress testing and usability testing.

At the top level, we had very few acceptance tests. These acceptance tests help stakeholders understand and validate software functionality.

24. What do you know about Distributed Transaction?

A distributed transaction is any situation in which a single event results in a mutation of two or more separate data sources that cannot be committed atomically.

In the world of microservices, it becomes more complicated because each service is a unit of work, and most of the time multiple services must work together for a business to succeed.

25. What is Idempotence and where is it used?

Idempotence is the property of being able to do something twice in such a way that the end result will remain the same, i.e. as if it had been done only once.

Usage: Use Idempotence in a remote service or data source so that when it receives instructions multiple times, it only processes instructions once.

26. What is bounded context?

Bounded context is the core pattern of domain-driven design. The DDD strategic design department focuses on working with large models and teams.

DDD handles large models by dividing them into different bounded contexts and clarifying their relationships.

27. What is two-factor authentication?

Two-factor authentication enables the second level of authentication for the account login process.

Figure 11: Representation of two-factor authentication – microservice interview questions

Therefore, assuming that the user must enter only a username and password, this is considered single-factor authentication.

What are the credential types for two-factor authentication?

The three certificates are:

Figure 12: Certificate types for two-factor authentication – microservices interview questions

29. What is a customer certificate?

A type of digital certificate that a client system uses to make authenticated requests to a remote server is called a client certificate.

Client certificates play an important role in many mutual authentication designs and provide a strong guarantee of the identity of the requester.

30. What is the use of PACT in the microservices architecture?

PACT is an open source tool that allows testing of interactions between service providers and consumers, isolated from contracts, to improve the reliability of microservice integration.

Usage in microservices for implementing consumer-driven contracts in microservices.

Test consumer-driven contracts between consumers and providers of microservices.

View upcoming batches

What is OAuth?

OAuth stands for Open Licensing Agreement.

This allows access to the resource owner’s resources by enabling client applications (such as third party providers Facebook, GitHub, etc.) on HTTP services.

Therefore, you can share resources stored on one site with another without using their credentials.

32. What is Conway’s law?

“The organization of any design system will yield a design whose architecture is the organization of communication

A copy.” – Mel Conway

Figure 13: Representation of Conway’s Law — microservice interview problem

The law basically tries to convey the fact that:

In order for software modules to work, the whole team should communicate well.

Thus, the structure of a system reflects the social boundaries of the organization that produced it.

What do you know about contract testing

According to Martin Flower, a contract test is a test performed at an external service boundary to verify that a contract meets the expectations of consuming a service.

In addition, contract testing does not delve into testing the behavior of the service.

Rather, it tests that the input & output of the service call contains the required properties and said response latency, and that throughput is within allowable limits.

34. What is end-to-end microservice testing?

End-to-end testing verifies that each process in the workflow works properly.

This ensures that the system as a whole works together and meets all requirements.

In layman’s terms, you can say that end-to-end testing is a test that tests everything after a certain period of time.

Figure 14: Test level – microservice interview questions

35. What is the use of Container in microservices?

Containers are a good way to manage microservices-based applications so that they can be developed and deployed separately. You can encapsulate a microservice in a container image and its dependencies, which you can then use to scroll the microservice of an on-demand instance without any additional work.

Figure 15: Representation of containers and how they are used in microservices-microservice interview questions

36. What is DRY in microservices architecture?

DRY stands for don’t repeat yourself. It basically promotes the concept of reusing code. This leads to developing and sharing libraries, which in turn leads to tight coupling.

37. What are consumer-driven contracts (CDC)?

This is basically a pattern for developing microservices so that they can be used by external systems.

When we work with microservices, there is a specific provider that builds it, and there is one or more consumers that use microservices.

Typically, providers specify interfaces in XML documents. But in a consumer-driven contract, each service consumer communicates the interface that the provider expects.

38. What is the role of Web RESTful apis in microservices?

Microservices architecture is based on the concept that all services should be able to interact with each other to build business functions.

Therefore, to achieve this, each microservice must have an interface.

This makes Web apis a very important enabler of microservices.

RESTful apis Are web-based open network principles that provide the most reasonable model for building interfaces between components of a microservice architecture.

39. What do you know about semantic monitoring in microservices architecture?

Semantic monitoring, also known as comprehensive monitoring, combines automated tests with monitoring applications to detect business failure factors.

40. How do we conduct cross-functional testing?

Cross-functional testing is the validation of non-functional requirements, that is, requirements that cannot be implemented as normal functionality.

How do we eliminate determinism in testing?

Nondeterministic tests (NDT) are basically unreliable tests. So, sometimes they might pass, and obviously sometimes they might fail.

When they fail, they re-run through.

Some ways to remove uncertainty from tests are as follows:

1, the isolation

2, asynchronous

3. Remote services

4, isolation

5, time,

6. Resource leakage

What’s the difference between a Mock or a Stub?

Stub a virtual object that helps run tests.

Provides fixed behavior under certain conditions that can be hard-coded.

Any other behavior of the stub is never tested.

For example, for an empty stack, you can create a stub that returns true only for the empty () method.

Therefore, it doesn’t matter if there are elements in the stack.

Mocks a virtual object in which some properties are initially set.

The behavior of this object depends on the set property.

You can also test the behavior of an object.

Such as:

For the Customer object, you can simulate it by setting the name and age.

You can set age to 12 and then test the isAdult () method, which will return true if age is greater than 18.

Therefore, your Mock Customer object applies to the specified conditions.

43. What do you know about Mike Cohn’s testing pyramid?

Mike Cohn provides a model called Test Pyramid. This describes the types of automated tests required for software development.

Figure 16: Mike Cohn’s Test Pyramid — Microservices interview questions

According to the pyramid, level 1 should have the highest number of tests.

At the service layer, the number of tests should be smaller than at the unit test level, but larger than at the end-to-end level.

44. What is the purpose of Docker?

Docker provides a container environment that can be used to host any application.

Here, the software application is tightly packaged with the dependencies that support it.

Therefore, this packaged product is called a Container, because it is done by Docker, so it is called a Docker Container!

What is canary release?

Canary Releasing is a technology that reduces the risk of introducing new software versions into production.

This is done by slowly rolling out the changes to a small number of users, then publishing them to the entire infrastructure, making them available to everyone.

What is continuous integration (CI)?

Continuous integration (CI) is the process of automatically building and testing code every time a team member commits a version-control change.

This encourages developers to share code and unit tests by merging changes into a shared version control repository after each small task is complete.

47. What is continuous monitoring?

Continuous monitoring monitors everything from front-end performance metrics in the browser, to application performance, to host virtualization infrastructure metrics.

What is the architect’s role in microservices architecture?

Architects in microservices architecture play the following roles:

Determine the layout of the entire software system.

Helps determine the partitioning of components. Therefore, they ensure that components are glued to each other, but not tightly coupled.

Write code with developers to understand the challenges you face in your daily life.

Advise the team developing microservices on certain tools and technologies.

Provide technology governance so that the technology development team can follow microservices principles.

49. Can we use microservices to create state machines?

We know that each microservice with its own database is a independently deployable unit of program, which in turn allows us to create a state machine.

Therefore, we can specify different states and events for specific microservices.

For example, we can define the Order microservice. Orders can have different states.

Transitions to Order state can be isolated events within the Order microservice.

50. What is reactive scaling in microservices?

Reactive Extensions are also known as Rx.

This is a design approach where we collect the results by calling multiple services, and then compile the composite response.

These calls can be synchronous or asynchronous, blocking or non-blocking.

Rx is a very popular tool in distributed systems, as opposed to traditional processes.

Full version Java interview questions address: Java backend questions integration