1.
Design a system for a car dealership where cars can have
different engines (e.g., petrol engine, electric engine). You want
to model cars and engines such that engines can be easily
replaced without needing to modify the car class.
2. In an application millions of temporary StringBuilder objects
are being created, due to which application is facing big system
wide GC pauses, how would you rectify the problem, assuming
that memory available can not be increased to great extent.
3. You have a 10 GB log file containing individual bank
transactions. The task is to efficiently process this large file by
filtering transactions with amounts greater than 10,000 and then
calculating the sum of those amounts
4. I have Employee Class with 200+ different fields inside it. I
want to serialize just 10 fields out of this 200 fields when
serializing this object. What is best way to achieve this?
5. For suppose u r getting an information from every request in
controller level... U need to utilise that particular info throughout
the project. What was your approach?
6. U will be having two lists... Assume one consists of locks
another were keys.. for every lock there will be only one nd only
one key... So match accordingly and print it...
7. Suppose we have a scheduled cron job in our spring app. Now
we have that app deployed on prod (multiple pods on multiple
servers) how do we ensure there is no duplicate work being done?
8. How Remove Consecutive Duplicate Elements from a List
using Streams?
9. Adding elements to binary search tree inorder traversal
- #oracle
[Link] a SQL query to find the value before ( parentheses
example: LOS ANGELES(LA). Output
should be LOS ANGELES#oracle
[Link] a java 8 program to merge the 2 arrays and sort them
and find the distinct elements in an array#oracle
[Link] the minimum element in the row and max element in the
column in a matrix#oracle
[Link] are 5 services. every service getting time to fetch the
record like 20sec, 10 sec, 1 min, 15sec each and this services
calling to other third party services, we don't have access of
third party services. and client is asking to you. why your services
getting time for the response. then how will you be handle
performance
[Link] ask me to draw architecture of your project
API core banking
[Link] i have API i need to get how many hits to website
[Link] api has 10 requests i need to consider only 5 first request
how to do that.
[Link] do u make sure about code quality.
[Link] postman we do test manually do we have automaticaed
process for it?
[Link] i book flight ticket u and i saw only one seat what if i tried to
access same time
[Link] class obj department,name,empid,designation find
employees with department id–used streams
[Link] i have a scenario where i have admin entering a employee
details which should reflect in db how to do–
controller,repository,service layers
[Link] we used same api for update as well? How it will be
saving in DB–save method–does save does new save or update?
[Link] do we know how the load balancer handles the
requests ? Let's say if there are n requests coming from a service
and there are 4 pods , how do we know whether the load is
equally distributed between each pod or not ?
[Link] asking how u can applied java8 and oops concpets
in you're project this question i got it from interview
[Link] next what are the challenges you faced in you're project
how you over come this one also
[Link] can you handle exceptions in production issues and how
can you provide security for your app
[Link]-fast vs fail-safe in java, Concurrent modification in java
and Solid principles
[Link] have to develop a banking application how you design it
they give me input like user name password and I want to tell
them how you fetch the record of accounts what you will do they
don't expect JWT part and how many services you write for this
application and how your data is coming
[Link] I use post instead of get this question I. Faced on
many interviews #hcl
[Link] he asked about some questions on streams wrt to enum.
He gave one enum and I have to iterate it and print
wrt to stream#hcl
[Link] is difference between interceptor vs filter#hcl
[Link] happens when send patch request when nothing
was there in db#hcl
[Link] I add an element to hashset which
declared as final #valuelabs
[Link] optional be serialized #valuelabs
[Link] do you handle exceptions in streams #valuelabs
[Link] a payload which has userinfo like
firstName,lastName,email etc for creating userInfo in db. If you
accept request body as a pojo what happens when the field name
and json keyname mismatches?Do you get error in that case?
[Link] will you accept json request body in its raw form so that
we can see which field in the request does not have proper name
and revert to the client?map/string
[Link] will you validate incoming json request body's schema?
What if instead of firstName payload has first_Name what data
type sent in the payload for a particular is different than
expected?How will u validate these things
[Link] a transaction is done by user end and the payment is done
but not reflected in your system what action you will take to
resolve the problem
[Link] do we create Google jobs in large scale by java
spring asked in #tcs
[Link] i have an api which should produce json response for
react input and xml for any another service(microsercice) input
how can you achieve it ?
[Link] there are 200 apis i have to include response time of
each api in apis payload how can i achieve it ?
[Link] a code to print the number of times occurrence of each
char in the string using the hashmap.
[Link] is the parent [Link] ?
[Link] can we join tables in microservices ?
[Link] between Micro service and restapi ?
[Link] cloud platform are you using ?
[Link] between jar and war files ?
[Link] to store the bulk of records in your database at a time?
[Link] can you fetch the data from Catche and radies without
hitting database N number of times ?
[Link] can you provide security in your user service and
implementation ?
[Link] scenario can we write a custom query and use of it ?
[Link] to convert Entity to Dto ,Dto to an entity and use it ?
[Link] is data optimisation ?
[Link] to store the data in Cache and redis in
microservoces,how to implement this..
[Link] need to design a system where different types of files
(e.g., text documents, presentations, spreadsheets) can be
created based on the user's choice. Each file type has its own way
of being created, saved, and deleted, but they all share the same
set of operations. How would you implement this using the
Factory Design Pattern in Object-Oriented Programming?
57.I was asked to solve leetcode 394. Decode String #mastercard
[Link] are given a paragraph , which contain n number of words,
you are given m threads. What you need to do is , each thread
should print one word and give the control to next thread, this
way each thread will keep on printing one word , in case last
thread come, it should invoke the first thread. Printing will repeat
until all the words are printed in paragraph. Finally all threads
should exit gracefully. What kind of synchronization will
use? #visa
[Link] I would handle pager duty alerts and debug production
issues #paytm
[Link] are multiple server having ram of 2gb where i have to
store the 2gb of the pdf, i have an api which convert the each row
of csv to pdf and there is another server where 5 gb of the csv file
is present. now question is how to do this process? I have told we
can use multithreading and do it but this is not the right answer ?
61.A restaurant waiter can serve food only after all the dishes
(Pizza, Pasta, Dessert) are prepared. Each dish is prepared by a
separate chef, and the preparation times for the dishes vary. The
waiter must wait until all the chefs finish their tasks before
serving the food. How would you design a multithreading solution
in Java for this scenario? Which Java class would you use to
ensure the waiter (main thread) waits until all chefs (worker
threads) complete their tasks? Why? Write a Java implementation
for this scenario, ensuring the waiter serves the food only after all
chefs have finished preparing their respective dishes.
[Link]: target = 7, nums = [2,3,1,2,4,3] Output: 2
Explanation: The subarray [4,3] has the minimal length under the
problem constraint.
Input: target = 4, nums = [1,4,4] Output: 1
Input: target = 11, nums =
[1,1,1,1,1,1,1,1] Output: 0 #Volkswagen
[Link] String s = "abcdabcdbb";
Length of the longest substring without repeating characters: 4
#smallscalecompanies
[Link][] input = {0, 1, 0, 1, 0, 0, 1, 1, 1, 0};
SeparateZerosAndOne #smallscalecompanies
[Link], Find 3 numbers result is 0
int[] arr1 = {0, -1, 2, -3, 1};
Answer : -3, 1, 2
-1, 0, 1
int[] arr2 = {1, -2, 1, 0, 5}; Ans -2, 1, 1 #Volkswagen
[Link] is. From the list of employees record (id, name, age,
salary) after sorted by name then we have to remove employee
records whose name is duplicate using streams.
[Link] are web services?? And how many we have ?
[Link] a GET API returns a large transaction history involving
multiple tables, causing latency when displaying data on a
dashboard UI, and pagination or lazy loading isn't an option, how
would you investigate the cause of latency? What approach would
you take to reduce it, considering you can't modify the database
(e.g., no materialized views)? #Societe Generale
[Link] you explain difference between normal integration of
order service and mail service in spring boot and integration of
order service and mail service using apache kafka #Accenture
[Link] api gateway is implemented in your project and
why ? #infogain
[Link] api gateway call any microservice internally ? #infogain
[Link] is fault tolerance ? how you have implemented in your
project ? #infogain
[Link] is circuit breaker pattern and its types ? #infogain
[Link] is saga pattern usecase/scenario ? explain #infogain
[Link] transactions are handled in distributed transaction
management system? #infogain
[Link] is circular dependency in spring ? #infogain
[Link] is N+1 problem in hibernate ? #infogain
[Link] threads, one printing even numbers and the other
printing odd numbers, need to print consecutive numbers from a
shared array in sync. For example, given the array [1, 2, 3, 4, 5,
6], the output should be 1, 2, 3, 4, 5, 6, with odd and even
numbers printed alternately. Can you make this work? #nagaroo
[Link] Java 8 , we can have concrete methods in an interface as
well . An abstract class can also have concrete methods. So,
design point of view and as per oops, which one to use when ?
[Link] between git merge and rebase
[Link] interview asked 1 question -> how you implemented
security in your application -> need Oauth2 explanation... Do we
need to give answer functionally or technically implementation I
couldn't understand ?
[Link] we have a scheduled chron job in our spring app.
Now we have that app deployed on prod (multiple pods on
multiple servers) how do we ensure there is no duplicate
work being done ?
[Link] your roles and responsibilities in your current
project ? #infogain
[Link] api-gateway implemented in your project and
why ? #infogain
[Link] is fault tolerance ? how u have implemented in your
project ? #infogain
[Link] of hashSet ? #datamatics
[Link] will you save millions of data into database using
hibernate ? #datamatics
[Link] type of cascades does JPA support ?
[Link] you have 2 threads. One of them prints (1,2,3…) and
the other one prints (A,B,C,..). How will you ensure that they run
in a sequence, so that it prints (1,A,2,B…)? #jpmorgan
[Link] are working on a railway application, and we have 5
railway ticket counters, and we need to distribute unique tokens
for each counter. How do you design this scenario
[Link] is Fault Tolerance
[Link] is cyclic dependency in spring
[Link] spring boot actuators and how can you restrict them to
a different kind of users
[Link] is Ouath token
[Link] token and its structure
[Link] is spring security
[Link] are ACID properties
[Link] is default scope in spring boot. When is prototype scope
is used?
[Link] are the different types of cascading in hibernate
100. How we authenticate azure functions?
101. What is key vault ?
102. Which library used for blog trigger?
103. How to authenticate user request? How you manage in
azure ?
104. What is CICD ? Explain CI
105. What is manage Identity?
106. How to secure azure functions?
107. If Java didn’t have the synchronized keyword, how would
you implement thread safety?
108. How would you store a billion records in memory while
ensuring efficient search operations?
109. Explain Java’s ClassLoader in a way that a 10-year-old
could understand.
110. What exactly happens inside the JVM when a
NullPointerException is thrown?
111. Design a traffic management system for a city with self-
driving cars.
112. If you had to reduce API response time by 50% in a
large-scale system, where would you start?
113. How would you design a video streaming platform that
adapts in real-time to network conditions?
114. Can you sort an array faster than O(n log n)?
115. You have an infinite stream of numbers. How would you
efficiently find the median at any point?
116. If you could only use one data structure for every
problem, which one would it be and why?
117. How would you explain recursion to someone who has
never coded before?
118. If you could remove one feature from Java, what would it
be and why?
119. Tell me something interesting about technology that
isn’t on your resume.
120. In Interview One question asked, One file is saved in one
directory so write java code to find the directory path of that file
121. They asked why lambda function is called anonymous. If
it return nothing then what is use of that. #sarvatra Technology
122. Difference between filter and interceptor #sarvatra
Technology
123. He given me one scenario of building ebook
platform. He wants me to write the rest Api architecture between
these microservices
1. Book 2. User 3. Search 4. Payment 5. Download
124. I have a list of strings, and inside the list, each string
can contain multiple words. I want to count the frequency of each
individual word across all the strings in the list using Java Streams
and find the words that occur most frequently.
Input:
List<String> sentences = [Link](
"apple banana apple",
"orange apple banana",
"banana apple"
);
Output:
Most frequent word(s): [apple]
Frequency: 4
125. Explain how polymorphism was used to calculate ETAs
differently for normal and priority deliveries. #flipkart
126. If a driver has to pick up vehicles from multiple
locations, how would you implement route optimization using
OOP?#flipkart
127. What is the purpose of super() in your child class?
Provide an example from your project.#flipkart
128. How would you use the static keyword for utility
functions in route optimization?#flipkart
129. Write a constructor for the Driver class to initialize the
driver object with essential details (name, availability, assigned
route). Use this to differentiate between local and instance
variables.#flipkart
130. Can a static method access non-static variables? Why or
why not?#flipkart
131. Why is the super keyword used in constructors? Can you
provide an example where super was used to extend functionality
in your project?#flipkart
132. What happens if a constructor doesn’t explicitly call
super() in a child class?#flipkart
133. In your project, if you wanted to add a new delivery
service with additional features, how would inheritance be used?
#flipkart
134. Real time:
135. If two customers schedule pickups for the same time but
only one driver is available, how would you prioritize one over the
other? Implement this using OOP concepts.#flipkart
136. If a driver has started their route but a high-priority
pickup request is added, how would you re-optimize the existing
route?#flipkart
137. If the MySQL database becomes unavailable during
scheduling, how would you ensure that requests are temporarily
saved and retried later?#flipkart
138. If a driver assigned to a route becomes unavailable mid-
route, how would you dynamically reassign tasks to another
driver?#flipkart
139. What are types of CI CD pipelines ?
140. How do you try to increase performance of a Java
application ?
141. 1)Springboot flow 2)Aws (what is lambda ,cloud watch
as I mentioned in my resume they asked it) 2) What are the
differences between kafka and rabbit mq 3)how did you optimize
sql queries in our project 4)Singleton class code and call if from
another class also create more objects for it using the code and
compare those objects using == and .equals what is the answer
and why? Rest services 5) @Request Mapping annotation
142. I have an Employee class in Java with two attributes:
userId and password. While sending an Employee object from one
server (s1) to another server (s2) over HTTP, I want to transfer
only the userId field and exclude the password field. What is the
best way to achieve this in Java?
143. How would you refactor a large class that is responsible
for both handling database operations and sending email
notifications to comply with the Single Responsibility Principle
(SRP)? What changes would you make, and how would you
structure the code to ensure scalability and maintainability?
144. How do we consume external API and build the
communication between internal and external API and how can
we authenticate the external API in microservice architecture.
Write a configuration code for that.
145. 1. You need to handle 1 million requests per second.
How would you scale your backend architecture?
146. 2. If you are building an order management system,
how would you design the services? (Database choices, API
interactions, scalability)
147. 3. Design a simple service that asynchronously
processes tasks using Spring Boot.
148. 4. You have a distributed system where one
Microservice must call another but should retry on failure. How
would you implement this in Spring Boot?
149. 5. You deployed a Spring Boot service, but it crashes
with an “Out of Memory” error. How do you debug this?
150. 6. Your Spring Boot REST API, which fetches data from
a database, suddenly becomes slow. The response time has
increased from 100ms to 3 seconds.
151. 7. Your Spring Boot microservice is running on
Kubernetes and after a few hours, it crashes with
OutOfMemoryError.
152. · What are the possible causes of
memory leaks in Java?
153. 8. One of your microservices has started consuming
high CPU (90%), even though the incoming traffic is normal.
154. · How to investigate and identify the root cause?
155. · What could cause a thread to enter an infinite
loop?
156. · How can you profile CPU usage in a running
application?
157.
158. 9. You start your Spring Boot application, but it fails
with a “BeanCurrentlyInCreationException” due to a circular
dependency.
159. How to debug and fix this issue?
160. What Spring mechanisms help break circular
dependencies?
161. Your Spring Boot app occasionally freezes and stops
processing requests.
162. How to detect a deadlock in Java?
163. How can you use jstack to diagnose the issue?
164. How can you avoid deadlocks in database transactions?
165. What is the parent class of all classes in Java. What are
the methods in it.
166. Difference between String and String Buffer?
167. If you are continuously manipulating the data in a list,
Which Collection you should use and why?
168. I need one [Link] you please share one project to
explain on the banking domain and microservic architecture and
security. One project with monolithic architecture on an aviation
project how springboot is used hibernate, jpa, security, db
connection. Deployment in both ways , monolithic, microservce
architecture. Could you please explain these concepts
for job interview.
169. can you please build some project (maybe medium
level) for each java design patterns
170. What is client side API Gateway
171. What is server side API Gateway
172. one real time example of when to use Abstract classes
173. one real time example of when to use Interfaces
174. 1. In an integer array containing repeated numbers, we
have to find repeated numbers sum in an array.
int[] a={2,4,2,6,4,7,2}:
Output - 2+4=6(sum of repeated numbers).
175. Find the occurrence of words in String
String s=" I love love india I respect ";
Output - > {I -2, love -2 ,India -1,respect-1}.
176. write getter function and avoid null pointer exception
using optional class #De