Crack your Java+Microservice Developer Interview with these Real Question & Answers Series-4 (Fintech company specific, Microservice/SQL)

I would be posting actual JAVA/Microservices interview questions and their answers asked during the interview. It will definitely help you to clear any Java Developer Interview. These questions are asked in finance and banking domain companies

Ajay Rathod
6 min readApr 16, 2022

(A bit of context: I’ve conducted numerous interviews for software engineering positions in most of the MNCs. Additionally, there have been instances where I faced challenges during coding interviews due to lack of preparation.)

Are you preparing for a job interview as a Java developer?

Find my book Guide To Clear Java Developer Interview here Gumroad (PDF Format) and Amazon (Kindle eBook).

Guide To Clear Spring-Boot Microservice Interview here Gumroad (PDF Format) and Amazon (Kindle eBook).

Download the sample copy here: Guide To Clear Java Developer Interview[Free Sample Copy]

Guide To Clear Spring-Boot Microservice Interview[Free Sample Copy]

by Christina Morillo

Few word of advice regarding banking/fintech companies

These companies can start asking from basic which you might feel is easy but, if you are not able to satisfy the interviewer that can cause rejection. So please brush up on basic OOPS concepts and Java basic, Exception handling, Solid Principles with examples and Association, Aggregation, Composition, and scenarios related to questions regarding Inheritance, Abstraction, and Polymorphism.

A few Questions can be confusing and needs utter focus and clarity of concepts. A few examples I can provide are below.

Abstract vs Interface (In terms of Java-8 perspective)

Abstraction vs polymorphism

Is-a Relationship vs Has-Relationship

These types of questions mostly depend on how much experience you hold. sometimes they might not ask basic but they will definitely check your problems solving skills like how you will approach a problem.

Spring-boot

What is the Spring bean lifecycle?

What are bean scopes and what are prototype and request bean scopes?

When you create a bean definition what you are actually creating is a recipe for creating actual instances of the class defined by that bean definition. The idea that a bean definition is a recipe is important because it means that, just like a class, you can potentially have many object instances created from a single recipe.

ScopeDescription:

Singleton-Scopes a single bean definition to a single object instance per Spring IoC container.

Prototype — Scopes a single bean definition to any number of object instances.

Request-Scopes a single bean definition to the lifecycle of a single HTTP request; that is each and every HTTP request will have its own instance of a bean created off the back of a single bean definition. Only valid in the context of a web-aware Spring ApplicationContext.

Session-Scopes a single bean definition to the lifecycle of a HTTP Session. Only valid in the context of a web-aware Spring ApplicationContext.

Global session-Scopes a single bean definition to the lifecycle of a global HTTP Session. Typically only valid when used in a portlet context. Only valid in the context of a web-aware Spring ApplicationContext.

How would you call a method before starting/loading a Spring boot application?

What is the Difference between @Component and @Service @respository @Controller annotations?

Purpose of each annotation:

  1. @Controller -> Classes annotated with this, are intended to receive a request from the client side. The first request comes to the Dispatcher Servlet, from where it passes the request to the particular controller using the value of @RequestMapping annotation.
  2. @Service -> Classes annotated with this, are intended to manipulate data, that we receive from the client or fetch from the database. All the manipulation with data should be done in this layer.
  3. @Repository -> Classes annotated with this, are intended to connect with the database. It can also be considered as DAO(Data Access Object) layer. This layer should be restricted to CRUD (create, retrieve, update, delete) operations only. If any manipulation is required, data should be sent be send back to the @Service layer.
  4. Technically @Controller, @Service, @Repository are all same. All of them extends @Component.
  5. From the Spring source code:
  6. Indicates that an annotated class is a “component”. Such classes are considered as candidates for auto-detection when using annotation-based configuration and classpath scanning.
  7. We can directly use @Component for each and every bean, but for better understanding and maintainability of a large application, we use @Controller, @Service, @Repository.

What @SpringbootApplication annotation does?

Using the @SpringBootApplication Annotation

Microservices

Which Microservice design pattern you have used so far and why?

A few of the popular patterns are below

  1. CQRS pattern
  2. SAGA patter
  3. Circuit breaker Pattern
  4. Service Discovery and API Gateway Pattern

Here is a good link for that — Pattern: Microservice Architecture

Which Microservice pattern will you use for read-heavy and write-heavy applications?

CQRS which is a command query pattern, CQRS stands for Command and Query Responsibility Segregation, a pattern that separates read and update operations for a data store. Implementing CQRS in your application can maximize its performance, scalability, and security. The flexibility created by migrating to CQRS allows a system to better evolve over time and prevents update commands from causing merge conflicts at the domain level.

What is the SAGA pattern is used?

The Saga design pattern is a way to manage data consistency across microservices in distributed transaction scenarios. A saga is a sequence of transactions that updates each service and publishes a message or event to trigger the next transaction step. If a step fails, the saga executes compensating transactions that counteract the preceding transactions.

What circuit breaker pattern have you used it?

If we want to stop any error cascading to another component/service in the microservice, to stop that we usually use circuit breakers.

What are the examples of it?

Hystrix library from Netflix and Resiliency4j are examples of it.

How to call methods Asynchronously, in the spring framework how can we do that?

Using @Async annotation with executors to achieve that.

How to call other microservice asynchronously?

There are a lot of options for asynchronous integration. Some of the widely used ones are:

Kafka

RabbitMQ

Google Pub/Sub

Amazon Services

ActiveMQ

Azure Services

Tell me about the Pros and cons of microservice architecture and why we need that (Justify what problem microservice architecture solves)

  • Pros of Microservices. Easier Scaling Up. Improved Fault Tolerance. Ease of Understanding of the Codebase. Scope for Experimenting. …
  • Cons of Microservices. Increased Complexity of Communication. Requires More Resources. Global Testing and Debugging is Difficult. Not Practical for Small Applications.

How to handle exceptions in the spring framework?

@ControlAdvice annotation- This is a global exception handler in the spring boot application.

How to break a singleton design pattern? and what can we do to stop that?

Scenario Based

How to build a restful web service that can fetch 1GB of data from the database and send it back without using Pagination, so the question is if you have a big size response how would you send it back from a rest web service?

How would you design a binary tree kind of data structure in database design, basically the interviewer wants to know how you would design a database in a hierarchical way.

How would you store millions of records in a table? How many tables does it require, any database pattern can you use here?

SQL/Database

How to store and navigate hierarchies?
In a database there is an index, what is the data type of the index?

Thanks for reading

  • 👏 Please clap for the story and follow me 👉
  • 📰 Read more content on my Medium (21 stories on Java Developer interview)

Find my books here:

--

--

Ajay Rathod

Software Engineer @Cisco | Java Programmer | AWS Certified | Writer | Find My Books on Java Interview here - https://rathodajay10.gumroad.com/