Interview Question Document
Must have skills and sequence
1. Data Structures & Algorithms (DSA):
Start by discussing fundamental problems like searching, sorting, and
linked list challenges. Ensure candidates understand time complexity. If a
candidate struggles significantly in this area, it’s advisable to reject them.
2. Programming Skills:
Assess the candidate’s ability to write solutions with optimal time
complexity. They should be able to use DSA algorithms where applicable.
3. Core Java:
Ensure candidates are well-versed with the latest Java concepts, especially
Collections, and have hands-on experience with JDK 8.
4. SQL:
Candidates should understand basic database concepts, such as
normalization and ACID properties. They should also be able to write
complex JOIN queries.
5. Spring Boot Concepts:
Evaluate their understanding of core Spring Boot concepts.
6. Microservices:
Lastly, assess their knowledge of microservice architecture.
Project Knowledge:
Explain the project flow, which layer is doing what and how?
How did you handle performance issues in your projects?
Can you provide examples of challenging scenarios you've encountered in
your projects and how you approached and solved them independently?
Explain a project you've worked on that followed design principles like
SOLID.
Java: (Multithreading only framework, Collection, Exception
Handling, functional programming): Must Have
What are the checked and unchecked exception and when should we use
each type of exception when throwing custom exceptions in Java.
Explain how interfaces promote loose coupling in Java applications
Fail fast and failsafe collections
hashCode() and equals() method contract
Is it necessary to declare all immutable objects as final?
Why to use Map and Set over an array.
Map: fast lookup, flexibility in key types, dynamic size, key based
operations
Example: Storing user preferences in a web application, where
each preference is associated with a unique user ID.
Using a map allows efficient lookup of preferences
based on user IDs.
Set: Unique elements, Efficient membership tests(contains), Mathematical
Set operations (union, intersection, subset), Elimination of duplicates
Example: Managing a list of unique usernames in a chat application.
Using a set ensures that each username is unique,
simplifying validation and preventing duplicates.
Explain the internal implementation of HashMap in Java, including
handling collisions, and the role of hashCode() and equals() methods.
Discuss Java 8 concepts and improvements. Must have hands-on
experience.
Find the occurrence of each character present in the given string using
java8 streams
Input: “Hello World”
Output: H – 1
O-2
l – 3 so on.
Explain multithreading concepts like the Executor framework.
Design Principles:
Discuss the SOLID principles.
Explain the Builder and Factory patterns.
Basic Data Structure with Time complexity: Must Have
Why use a binary search tree for searching instead of other techniques?
Implement sorting and searching algorithms (e.g., bubble sort, merge sort,
binary search) with space and time complexity analysis.
Linked list problems
Problem Solving skills consider best time complexity: Must Have
Mean Value Calculation: Calculate the mean value from an array.
Finding the Missing Element: an O(n) solution and O(log n) approach.
Write a program to calculate the sum of digits of an integer considering
inputs k and n.
For example, k = 4, n = 9578
input x = "9578957895789578"
9+5+7+8+9+5+7+8+9+5+7+8+9+5+7+8 = 116
1+1+6= 8
8
Output should be 8 in above example.
Hint: Get sum of digits of each output as well until you get single
digit and that should be your final output
Write a program to find pairs of integers in an array whose sum equals a
target value.
Given an array of positive integer numbers and an integer k, find the
length of the longest subarray whose sum is less than or equal to k.
Ex. 1 Input: arr = [3, 1, 2, 7, 4, 2, 1, 1, 5] and k = 8 Output: 5 [3, 1, 2, 1,
1]
Ex. 2 Input: arr = [10, 2, 5, 7, 1, 9] and k = 15 Output: 4 [2,5,7,1]
Given a sorted array of integers, return an array of the squares of each
number sorted in non-decreasing order.
Input: arr = [-4, -1,0,3,10]
Output: [0,1,9,16,100]
Given an array of numbers, find the maximum sum of subarrays from
these subarrays and perform sorting using insertion sort.
int[] nums = {1, -2, 3, 4};
Sorted subarrays by sum:
[-2]
[1]
[3]
[4]
[1, -2]
[3, 4]
[1, -2, 3]
[1, -2, 3, 4]
[3, 4, -2]
[4, -2]
[4, -2, 3]
[4, -2, 3, 4]
[3, -2]
[3, -2, 3]
[3, -2, 3, 4]
[3, 4, -2, 3]
[3, 4, -2, 3, 4]
[4, -2, 3, 4]
Maximum sum of subarrays: 8
You are given a list of ranges, where each range represents a numeric
interval and is associated with a specific value. The ranges are sorted
based on their start values. Your task is to implement a method to
determine if a given number falls within any of the ranges. If the number
falls within a range, return the index of the range in the list. If the number
does not fall within any range, return -1.
Input: List<Range> list = new ArrayList<> ();
list.add(new Range(81, 100, 'A'));
list.add(new Range(61, 70, 'B'));
list.add(new Range(25, 55, 'D'));
list.add(new Range(72, 75, 'C'));
You are given a list of orders placed by customers, where each order
contains the following information: order ID, customer ID, order amount,
and transaction date. Your task is to process this data and generate a
summary report showing the total order amount for each transaction date.
Spring Boot:
How would you implement a retry mechanism for calling an external
service in a Spring Boot application?
How would you implement caching in a Spring Boot application to improve
performance?
How can you use Spring Boot's profiling feature to manage environment-
specific configurations?
How would you implement authentication and authorization in a Spring
Boot application?
What are some commonly used endpoints provided by Spring Boot
Actuator, and how would you use them?
Write Spring Boot code with annotations covering Controller, Service, and
Repository components, adhering to design principles like SOLID and
including exception handling and functional programming.
What happens if you put @Component and @Service both in a class?
Microservice:
How will you decide how many microservices you need to have?
What are the factors you will consider while creating the microservices?
How should microservices be scaled?
When do you need to scale horizontally?
Explain design patterns like API Gateway and circuit breakers.
What is the difference between Rest Template and Web Client?
Design a system where one microservice gets 100 empIds in the request
and needs to make another microservice call to get salary details, given
that the salary microservice can only take 1 empId at a time.
Solution:
Will prepare and pass parallel requests to Emp Salary
micro-Service using some parallel mechanism like
parallel Stream or Executor Framework
Call to microservice using web client to serve the request
in non-blocking manner
We can add Circuit breaker to handle downtime of Emp
Salary microservice
Add Retry mechanism
Database/SQL:
Normal forms
ACID properties
Compare RDBMS and NoSQL databases.
Difference between CHAR (100) and VARCHAR (100)
What is partitioning in database on column level and why it is needed
Write an SQL query to select the top 5 customers of each city who have
made the most transactions between Nov 1 and Nov 30.
Customer (customerId, name, city)
Order (Productid, customerId, price, date)
WITH RankedTransactions AS (]]]
SELECT
o.customerId,
c.city,
COUNT(o.orderId) AS transactionCount,
ROW_NUMBER() OVER (PARTITION BY c.city ORDER BY
COUNT(o.orderId) DESC) AS rank
FROM
Customer c
JOIN
Order o ON c.customerId = o.customerId
WHERE
o.date BETWEEN '2022-11-01' AND '2022-11-30'
GROUP BY
o.customerId, c.city
)
SELECT
customerId,
city,
transactionCount
FROM
RankedTransactions
WHERE
rank <= 5;
Write an SQL query to remove duplicates from a EmployeeDetails table
without using a temporary table.
EmployeeDetails(EmpId(PK) FullName ManagerId DateOfJoining
City)
DELETE E1 FROM EmployeeDetails E1
INNER JOIN EmployeeDetails E2
WHERE E1.EmpId > E2.EmpId
AND E1.FullName = E2.FullName
AND E1.ManagerId = E2.ManagerId
AND E1.DateOfJoining = E2.DateOfJoining
AND E1.City = E2.City;
Write a query to fetch the department-wise count of employees sorted in
ascending order.
EmployeeInfo (EmpID, EmpFname, EmpLname, Department, Project,
Address, DOB, Gender)
EmployeePosition (EmpID, EmpPosition, DateOfJoining, Salary)
SELECT Department, count(EmpID) AS EmpDeptCount
FROM EmployeeInfo GROUP BY Department
ORDER BY EmpDeptCount ASC;
What is Left outer join is MySQL?
- There is a foreign key in the employee department. And I have a scenario
where I need to delete a department. As soon as I delete a department, I
want all the employees from that department to get deleted. How can we
achieve this?
Kafka (As per the requirement)
1) Explain Kafka.
2) Why did Kafka use only for live streaming not other messaging systems,
how you have implemented.
3) Basic components or terminologies in Kafka like broker, topic, producer,
consumer. Serde, Avro messages
4) What all configurations are needed to create producer or consumer
5) How to create Kafka stream on a topic?
6) What is partition and its advantages in Kafka?
7) What is repartition and when it is needed
8) Exception handling in Kafka like DeserializationExceptionHandler,
ProductionExceptionHandler
9) How to avoid duplicate records at consumer side
10) How to consume records concurrently
11) What is ISR (In sync replica)?
12) How to write unit test and integration test to test Kafka topology
flow?
13) What is a consumer group?
14) There are 40 partitions in a topic and only 10 consumers. How is the
division of work?
15) You have 40 partitions in a topic, but there are 80 consumer
instances. How is the division of work?
16) When will be the rebalance trigger?
17) Out of 80 consumers, 1 left and 79 are there. Do you see the
rebalance happening?
18) Let’s say there is a topic whose retention is 7 days. I'm sending a
message from the producer to the topic, but there are no messages on the
topic. What could be the reason?
19) If the timestamp is older than the retention, then it will get deleted.
Will it get deleted immediately?
20) Schema registry?
21) Any knowledge on AVRO?