This content is a transcript of a technical interview for a Java Spring Boot and Microservices developer, covering a wide range of topics from multithreading and concurrency to Spring Boot features, API design, and Git best practices.
Mind Map
Click to expand
Click to explore the full interactive mind map • Zoom, pan, and navigate
Uh hey guys today we have Salvin he is
having total 4.8 year of experience in
Java spring boot and microservices
domain and those who want to give same
free mock interview please fill out the
form below in the description. So now
let's get started. Hey hello Salva how
are you?
>> Yeah yeah hi van I'm good how are you?
>> Yes I'm also good shall we start?
>> Yeah yeah yeah sure
>> so can you please introduce yourself and
your recent project in brief?
>> Sure as you said I am SA I have 4.8
eight years of experience in fullstack
development and speaking of my uh text
stack I'm primarily focused on Java with
springboard framework and in the front
end I'm more familiar with angular and
uh to the extent I worked on react as
well and speaking of database I have
worked on postgress uh SQL and RDS and
apart from this um uh I have worked on
various cloud services like S3 SQS blob
and various other services as well
>> and speaking of my current project. So
it's a integration project where our
client have their own CRM uh and their
clients are using both their own CRM and
other CRM tools like Microsoft Dynamics
and Salesforce. So they just wanted a
integration platform where they could
integrate their own app into the
Microsoft Dynamics like an iframe and
they wanted to data flow between the
Microsoft Dynamics and their own CRM. So
as a first phase we are integrating with
the Microsoft Dynamics and we are aiming
to integrate with others platform like
Salesforce uh Zoho in the upcoming uh
>> Got it. Got it. So how how can we make
our application uh concurrent
do you know?
>> Uh yeah so uh to make our application
you know in a concurrent way we could
use multi-threading to stimulate
multiple threads to run in a parallel
manner. Okay. Okay. Let's say there is a
method and two threads are trying to uh
get that methods. Uh that method is
basically counting a variable. So what
will happen? >> Uh
>> Uh
uh it will result in you know uh
unfamiliar situation. So here uh to
handle the you know thing to declare the
variable we could use you know atomic
integer for the variable. Else we could
declare the method as synchronized so
that multiple threads >> okay
>> okay
>> won't be handling the method at the same time.
time.
>> Okay. So do you uh do you know the life
cycle of a thread in Java?
>> Yeah. So first it will be in the new
state then it will uh it will be in
ready and runnable and in case there is
any weight or loss it will be in the
waking state or else in sleeping state
and again it will be runnable then it
will get terminated.
>> Okay. So can a thread go from waiting
directly to running?
>> U I guess yes. Uh only the thread uh
which we put it into sleep we need to
notify it again. And in case if it is in
a waiting state I guess u it will
>> um no a thread in waiting must first
move to runnable.
>> Yeah. Yeah. Sorry.
>> Then running. >> Okay.
>> Okay.
>> Yep. Yep.
Um okay. And what's the difference
between blocked and waiting? uh waiting
which is you know something uh which
coders usually they do it on manually
and blocked is something when the thread
is you know uh blocked by other thread
for waiting for the resource or other
similar situation.
>> Okay. Okay. What's the difference
between runnable and callable?
>> Um I haven't used callable but I have
used runnable interface. So where we'll
be overriding the run method to start
the new thread.
>> Okay. Okay. So you know callable works
with executor service do you know?
>> Uh uh not much about the service.
service. >> Yeah.
>> Yeah. >> Okay.
>> Okay.
>> Okay. So uh we know uh by using
synchronized uh we can make our method
thread safe right but I I just want to
know the limitations of using
synchronized keyword.
actually using a synchronized it
acquires a the thread acquires a log for
the method and the other threads which
are trying to access they need to wait
the log to be released. So here that you
know uh the other thread might be in a
waiting state. Uh
>> so this will be one thing which we need
to consider and apart from that um maybe
uh to the extent I guess it can result
to the race condition as well where if
the each like two method gets logged and
method A needs a resource from method B
and method B needs a resource from uh A.
So this may may uh result in a race
condition as well.
>> Okay. Hey guys, I want to share
something important with you. Actually
Salva prepared from our interview
preparation kit and cracked multiple
interviews. We have also referred him to
the multiple companies. So let me tell
you this interview preparation kit has
four main parts. First is complete
interview preparation material. It is a
step-by-step material made by me expert
and MNC's interviewers. 99% of the
questions asked in interviews are
covered in it. Second is two real client
enterprise projects. Code and video
recorded sessions are there and you can
add these in your resume. Third is
lifetime chat support. Here you can ask
your doubts anytime. Fourth is referral
support. Here we help you get referred
to the top MNC's. So guys basically the
material is organized as per your
experience level and covers Java, spring
boot, spring security, spring data, JPA
microservices, Kafka, Maven Git coding
question, stream questions and many
more. You can buy just a complete
interview preparation material or the
full kit with project supports and
referrals. I have added the links in the
description below. So now moving to our
interview. And guys before moving to our
interview, I would like to know the true
feedback of this kit uh by Selva. So
Selva, can you please give a feedback?
>> Uh sure. Yeah. So when I started
preparing for interview, I was looking
for you know uh single point where I
could complete entire Java from the
basics to uh spring boot microser and
everything at one place. So I couldn't
uh you know find any material and uh so
randomly I came across your video and
saw them material and I bought that and
it was too helpful for me to you know
prepare everything uh with a single
material. So okay yeah thank you. Um now
moving ahead so Salvas we discussed the
limitations of synchronize. So can you
tell me what's the difference between
synchronize and lock APIs? U so as I
said synchronized uh you know uh the
thread acquires a lock for the method
and once the you know method execution
completes and the log gets released and
uh lock API
uh I'm not sure about it. Uh do you know
Uh
I guess uh kind of similar to
synchronized. Uh
>> no no uh like in synchronize we are able
to uh block all meth whole method by
using keyword but we can do customized
things like we can lock anywhere and
lock anywhere. We can use try lock
in the reload.
>> Anyways it's fine. Um
>> just moving ahead. Uh so your
application slow under load. So what
would you do?
>> Uh you mean uh during the high traffic?
>> Yes. Yes, during the high traffic.
>> Uh I guess we need to you know scale our
application uh where we can scale it you
know vertically or horizontally. So
scaling vertically is like increasing
your environment
like increasing the RAM and everything
and scaling you know horizontally is
like scaling in the other instance of
your same application.
>> Okay got it. Uh so Salva can you tell me
the difference between hashmap
synchronize map and concurrent hashmap?
Uh yeah so you know hashmap u you know
allows you to store a key value pair and
the difference between the hashmap and
synchronous hashmap is like hashmap is
not thread safe and synchronous hashmap
you know it's the thread safe and
difference between the synchronized and
concurrent hashmap is like how they you
know block the map so one is like block
the bucket scope and uh the other will
be the element scope
uh synchronize I I I'm not sure like it
locks the whole bucket. Uh
>> okay. So what if I want to make a
hashmap uh thread safe? So I can use uh
synchronize map. >> Yeah.
>> Yeah.
>> Collections synchronize map right. Uh
but uh concurrent hashmap is faster
because it doesn't log whole map
otherwise synchronize map log whole map
not at the bucket.
>> Yeah. So yeah uh you know uh in the
multi-threading environment we can use
both synchronized and concurrent. So in
just if you are looking for performance
we can go for concurrent since it's only >> um
>> um
>> it's not the bucket level.
>> Yep. Yep. Okay.
Okay.
Um so can you please tell me uh your
spring boot application works locally
but fails on the server.
So what would you do? Uh
Uh
I'll look for the logs. So u you mean u
uh fails on the server in the sense how
we are trying to
>> means uh is it enment or production environment.
environment. >> Okay.
>> Okay.
>> The error is something like URL
okay I haven't faced this error but
maybe the configured URL uh is like
misformed or uh uh same thing. So I'll
debug in the application.properties
to configure the correct URL.
>> Yeah. So URL is not specified. It means
uh we are missing the URL or something
uh in the production environment or
server environment. But that's there in
our local dev environment. Something
>> Got it. Okay.
Okay.
So, how does the spring boot decide with
which application ML to load?
U we have a concept called profiles
where we'll be you know specifying which
application properties file which it
needs to be take where we can u give
spring profile active equal to dev work
or QA or staging whichever the
environment uh we need to load
>> okay what if what happens if both
application properties and application exist
exist
>> uh I guess yl takes a precedence over property
property Okay.
Okay. Um
Um
actually the both dot properties and ML
follow same priority rules.
Uh the one loaded later in order wins.
>> Okay. So it it is something uh spring
container or
>> Yeah. Yeah. Spring container decides. >> Okay.
>> Okay. >> Okay.
>> Okay. Um
Um
uh have you seen no unique bean
uh I guess this is a scenario where
we'll be getting if multiple beans of
same type or depend on u in the
dependency class where we haven't
specified which
>> correct correct
>> needs to be you know
>> if two or more uh same beans are qualified
qualified
>> yeah uh we can you know rectify by using
a qualifier or primary annotation
>> okay let's say there are two such beans
and you have added primary annotation in
both of the two beans. So what will
happen now? >> Uh
>> Uh
I haven't gone through this situation
might be resulting in circular
dependency error or
>> again uh there will be there will be
same situation no unique definition exception.
exception.
>> Okay. Okay.
>> Because both are now qualified with
[clears throat] primary annotation. >> Okay.
>> Okay. >> Okay.
>> Okay.
Okay. So what's the difference between
primary and qualifier annotation and
>> Um no other at the qualifier we'll be uh
passing the class name of which uh uh
bean it should take and other qualifier
annotation we won't be passing any
parameter and by default u uh the it the
class be uh takes the residence. >> Okay.
>> Okay.
Um okay got it. Uh let's say your
application fails with circular
dependency error after a recent change
code change.
>> So tell me how would you resolve this?
Um I'll check for the you know uh recent
change class where uh in case if a bean
we are injecting uh if we are using a
constructor based injection so that
might be uh resulting in a circular
dependency error to rectify it we can
you know move it to the
field based injection using autoation so
that the you know dependency class gets
loaded first and uh the Venus gets
injected to the other dependency class Yeah.
Yeah.
>> Okay. Um Okay. So, can you please tell
me why does constructor injection expose
circular dependencies but field
injection may not?
>> U constructor you know is called the you
know uh instantiation time itself.
>> So uh even at the time of bean creation
we need to call the constructor and um
uh same other time we need the
dependency bean as well. But u uh you
know a fieldbased injection doesn't need
a uh you know bean at the you know uh
the time of calling constructor. So
after calling the construction uh then
the dependency is getting injected into
the class. >> Okay.
>> Okay.
Um got it.
Um do you know about n plus1 query problem?
>> Uh no >> no.
>> no.
Um it's fine. So have you worked with
spring data JPA? >> Yeah.
>> Yeah.
>> Okay. So what's the dependency name of Spring?
Spring?
>> Uh we were using Spring Data JPA for SQL
database connections. Yeah. >> Okay.
>> Okay.
Uh what's the difference between custom
queries and
uh custom query we can you know if we
are having any complex queries like
which includes multiple joins and
something we'll be writing our own uh
query with the you know annotation of
the red query >> okay
>> okay
okay so let's say inside a transactional
method I mean there is a method and you
have valid transactionation
you throw an exception but data is still
get saved Okay.
Okay. >> So,
>> So,
>> u I guess yeah uh yeah um I guess in
this scenario u check the exceptions are
not handled uh using the you know the
transaction annotation. So I I guess
that's a case where uh the data gets
still processed into the mod.
>> Yes that's correct. Spring boot actually
rolls back only on unchecked exceptions
like runtime exceptions and error.
Checked exceptions do not trigger roll
back unless configured. we can configure this.
this.
>> Yeah. Okay. >> Okay.
>> Okay.
>> And what if the method is private?
>> Uh if it is private, I guess the
transaction annotation doesn't work uh
on the private method.
>> Okay. Transactional basically is ignored.
>> Okay.
Why does calling a transactional method
U from the claim. So you mean to say uh
you're having transaction at a different
method of same class. >> Mhm.
>> Mhm. >> Uh
>> Uh
uh I guess you know uh uh the
transaction internally creates a proxy
of the class. So maybe annotating with
multiple you know transaction annotation
might result in abnormal behavior of the proxy.
proxy.
Okay. Um do you know about uh lazy
Um yeah uh I mean in the entity when you
are having multiple relationship. So you
have an option of you know lazy and
eager initialization where uh in the
lazy uh the sub entity is not get loaded
uh without being called and in eager it
is getting being called and uh by
default I guess it's uh configured too lazy.
lazy.
>> Okay, got it.
um so how would you do pagination and
sorting in the rest API?
>> Uh the spring data JPI uh
by default have uh this pageable uh and
sorting thing. So where we'll be having
the page number and uh page size. Uh so
we can configure uh you know uh we can
get that using the query params uh in
the URL and uh by passing that uh into
the query u we can do the paging.
>> Okay. Um
let's say service A call service B and B
is down. Now A starts failing.
uh we can implement multiple design
patterns to handle this. So uh one will
be circuit breaker design pattern where uh
uh
>> we have three state uh closed, open and
uh you know half open. So say if service
A is trying to call B and B is down
we'll be cutting down the connect you
know calls to the service B and uh
randomly so say for example on 10 calls
for the two calls we'll be checking if
the service is up or not so this will be
now open and if those two calls are
successful again the state is moved to
uh closed uh >> okay
>> okay
um what's the difference between retry
the circuit breaker uh you know
completely shut downs the API calls and
u retry you know uh we'll be configuring
the back of time as well so uh say for
example if I'm configured 5 seconds so
again after 5 seconds so the service
again try to communicate with the
downstream service
U in case of rate limiting say if in a
particular minute probably the n number
of calls are allowed and uh so for
example in 1 minute you could take only
10 calls and after on 11th call you'll
be getting
error and again after 5 seconds if you
are hitting the same API again uh again
you'll be getting the same error so you
need to wait for the cool down period so
here uh you can't use retrain Okay.
Okay.
Can you explain the saga pattern with a
real example?
>> Yeah. So, Saha pattern can be
implemented using two you know methods.
So, one will be choreography and other
will be orchestration. So, in the
orchestration a single micros service uh
will be responsible uh for entire
orchestration. Say for example if I have
payment order and notification. So once
order is created we need to complete the
payment and once payment is done we need
to trigger a notification. So uh in
orchestration the payment sorry the
order service will be responsible
everything. So it will be communicating
with the payment and once payment done
it will be communicating to the notification.
notification.
>> Uh in the choreography each service will
be responsible uh for the transaction.
So once order completes the order
service it will be notifying the payment
and once payment completes payment will
be notifying the notification
>> shipping service. >> Yeah.
>> Yeah. >> Okay.
>> Okay.
Um do you know about compensating transaction?
>> Uh no.
>> Okay. Uh basically it is a transaction
uh that undo a previous successful step.
For example, refunding payment after
shipping fails.
>> Uh okay. Uh is it kind of uh roll back mechanism?
mechanism?
>> Um it does not roll back database state
like a transaction but logically reverse
business action. Um it is used in sagas
to handle partial failures sometimes. >> Okay.
>> Okay.
>> Yep. Um let's say a new version of your
API breaks existing clients. Okay.
>> So what would you do?
>> So uh we just have to ensure the
backward compatibility if you are
creating a new version. So we can just
have our versioning in the you know URL
so that uh the old version u you know
gets retained and new version uh users
are using the new one without any uh data.
data. >> Okay.
>> Okay. Um
Um
so while upgrading the versions we could
do three things URL upgradation, header
upgradations, media type versioning. >> Mhm.
>> Mhm.
>> So what do you think which is the best
uh I guess if the user can't uh you know
um uh modify the URL or something we can
go ahead with the you know headers and
um so uh first option will be header and
uh second will be modifying the URL and
third will be modifying the you know
content type. >> Okay.
>> Okay.
Okay. So I just want to know how would
you deprecate API safely the older
versions of APIs?
>> Uh uh we could you know uh create a new
version and uh keep supporting the older
version and I know u tell the users like
it will be going to you know uh [clears throat]
[clears throat]
>> deprecated uh so on so time. So we could
give them adequate time to you know uh
migrate their codes and version as well.
And uh after that we could uh
decommission existing.
>> Okay. So what do you use uh for secrets
for storing the secrets of your application?
application?
>> Uh we have various wall provided by the
you know uh cloud providers. So we could
uh store it in a key wall for example
and uh at the time of boot up we could
uh get the data uh key values from the wall.
wall. >> Okay.
>> Okay.
Um, got it.
Um, and how do you rotate secrets
>> Uh, without restarting the application.
>> Uh, we could have the secrets configured
uh uh in the configuration class instead
of uh properties. Fine. So [clears throat]
[clears throat]
>> and yes this is actually a feature also
uh like vault there is a vault app app
refresh secrets periodically or
>> my actuator refresh >> right.
>> right.
Yeah. And uh say for example uh you know
loading the keys at the application
startup we could avoid that and we could
uh get the key whenever uh uh response
uh uh it needed so that a new key gets
you know pulled up every time instead of uh
uh
loading at the starting of the application.
application.
>> Okay. Um Okay. So let's say your
application compiles uh successfully but
fails at runtime due to version
conflicts of dependencies.
So how would you resolve these
dependencies versions?
>> Uh we could have a you know uh parent
versioning uh defined as the you know
parent dependency or the you know uh the
spring boot uh itself uh so that uh it
the other dependencies take the version
of the parent uh dependency.
>> Okay. Um can you tell me the difference
between dependency management and
>> Uh dependency is like you know uh
indicating the single uh uh dependency
uh uh thing and I guess dependency
management is like uh uh managing the
whole uh dependencies. >> Okay.
Um what's the difference between clean
>> Uh and clean and install, right?
>> Yes. Yes.
>> Uh the clean, you know, cleans up all
the catches and uh the junk data and
install, you know, uh builds the application.
application.
>> Yeah, it pulls the new dependencies and everything.
everything.
>> Okay. Okay. So let's say I just want to
build my application through install but
at the same time I just want to skip all
the test cases for now. So how would I
do that?
>> Uh in the you know pom.xml you have uh
the tag skip test. So where you could uh
uh mention it as true so
skip test. Yeah.
>> Yeah. Skip.
>> Yeah. Uh you can have it as true and it
will skip all test. M okay
got it.
Um let's say a bad commit is pushed to
main and deployed. So >> Mhm.
>> Mhm.
>> and now application started uh failing.
So what would you do?
>> Uh in case if we are using you know a
docker image to deploy the application,
we could reverse back it to the old
image version. um else we could you know
uh revert it back to the
commit redeploy the application.
>> Okay. What's the difference between get
>> Uh revert we would be passing the you
know uh the commit ID which uh uh uh
which commit it has to be reverted.
reset you know uh if someone uh pushed
the code and uh I pulled it to my remote
uh my own desktop and again they
reverted back so uh if I'm uh you know
pulling again I need to reset my uh base
>> okay
um uh let's say you have created one
feature branch from the existing main
branch right
>> now in your feature branch there are
more than 20 30 commits Right now you
want to merge your feature branch into
the main branch. But you don't want to
push all uh the commits into the main
branch. You want to push only few two
three commits. So how would you do that?
>> Uh I could cherry pick my commit uh uh
whichever I need to be uh pushed and uh
it will create a new branch and from
that branch I could raise PR and move
only those.
>> Okay. Okay.
Why sometime rebase is dangerous on
>> Uh I guess uh it removes the history of
what have been modified and something.
So uh
>> it changes commit issues.
>> Yeah. So it might be uh uh you know
dangerous for the other developers who
are working on this.
>> Correct. So how how do you resolve the
>> Uh we have various methods. So I used to
use G desktop and VS code combination
where uh every uh uh conflict files will
be go shown in the desktop and uh we
have an option to open it and visual
code and uh resolve it there.
>> Okay. What's the best practices to avoid
get conflicts?
uh uh before start working we just have
to uh uh you know uh check whether we
are up to date with the main branch. So
if not we have to take a pull uh and
merge it with our working branch and uh
>> got it and what's the best practices of
Uh
we have to you know have proper uh
status code configured uh for every uh scenario
scenario
>> and uh errors are properly handled and
uh proper error message or uh logged for
debugging purpose and proper error
message are sent to the user for clear understanding.
understanding. >> Okay.
>> Okay.
Can you tell me uh some most uncommon
annotations that we don't use frequently
but are important
>> uh in case of AP? No, no. Spring in a
uh
I'm uh I'm not getting the name but uh
every time when we need to uh you know
get the values from the properties file
we use other annotation uh called value
uh it loads single value single uh key
at the time but there is this annotation
where if you're It loads the entire
key addressing window. I'm not getting
the [clears throat]
>> at the rate async we don't use
frequently, right? Um
>> yeah. Uh other
>> enable caching.
>> Yeah. Yeah. Other cachable. >> Cachable,
>> Cachable,
right? We don't use these annotations frequently.
frequently.
>> Okay. So in the
uh JWT token right
>> uh basically I just want to what I want
to ask what JW token consist it has
three parts right. >> Mhm.
>> Mhm. >> Yes.
>> Yes.
>> Uh it has header uh and the uh main uh
you know body where we'll be storing our
key values and the signature part as well.
well.
>> Okay. So what is this signature?
>> So uh signature is you know something
which is used to identify like uh who is
the uh issuer like and uh again for
checking like whether it is not tampered
or not.
Uh sorry uh I was telling in the secret
part signature uh
>> like SHA 256 SHA 512.
>> Yeah. Yeah. So uh for which hashing
algorithm uh which we need to use while
encrypting the >> okay
>> okay
um so okay so let's say uh your junior
is working on some feature. Okay. and he
started pushing
his code into the main branch. Then he
started uh deployed in production. Okay.
Now there are some issues. Production
environment is failing and that feature
is very very important. Uh we need to
resolve that feature uh within 24 hours
or within a day itself. So what would
you do? Would you guide him to resolve
the issue or would you take would you
pull the branch and do yourself
because that's a priority one.
>> So uh is it something which is working
in his local but only failing in uh production?
production?
>> Uh it may work it may be working in his
local or not we don't know since you are
you haven't worked with him so you don't know.
know.
>> Okay. So uh initially I just go through
the you know u PR changes which are uh
gone through the commit. So and since
it's the most uh important production
work so instead of waiting for my junior
so uh I'll just first try to resolve it
uh on my own uh so that it won't affect
any you know customers who using the
application and
>> so I'll be pushing the code and I'll be
testing it and fixing it and post that
I'll be informing him uh in case if it
is very urgent I could go for a hot fix
and inform him about the you know issue
and go for a real fix instead of walk around.
around.
>> Okay, got it. Uh, so yes, Selva, it's
Click on any text or timestamp to jump to that moment in the video
Share:
Most transcripts ready in under 5 seconds
One-Click Copy125+ LanguagesSearch ContentJump to Timestamps
Paste YouTube URL
Enter any YouTube video link to get the full transcript
Transcript Extraction Form
Most transcripts ready in under 5 seconds
Get Our Chrome Extension
Get transcripts instantly without leaving YouTube. Install our Chrome extension for one-click access to any video's transcript directly on the watch page.