Capgemini Java Developer 4 yrs interview Questions and Answers L2 round #capgemini
Summary
TLDRThe conversation revolves around a job interview for a Java developer role. The interviewer asks technical questions regarding Java, Spring Boot, microservices, and related technologies. The candidate discusses their experience with Java 8, Lambda functions, stream APIs, and their involvement in API development using Spring Boot. They also address scenarios on sorting employee data, writing custom queries, and handling API requests. The discussion extends to testing methods, such as JUnit, and the candidate expresses interest in learning more about microservices architecture.
Takeaways
- 😀 The candidate is a Java developer with 4.1 years of experience.
- 📍 The candidate is currently based in Gorakpur, UP, and willing to relocate to Bangalore or Chennai for work.
- 💻 The candidate has experience in banking and healthcare domains, working with Java, Spring Boot, and MySQL.
- 🔧 The candidate is proficient in using Java 8 features such as Lambda expressions, Stream API, and Optional class.
- 📝 The candidate is asked to write Java code to filter employees based on location and sort a list of employees by name and age.
- 🛠 The candidate discusses the use of functional interfaces like Predicate, Consumer, and Supplier in Java.
- 📈 The candidate is familiar with Spring Data JPA and its advantages over traditional Repositories.
- 🔄 The candidate explains how to design an API to fetch the first five records from an employee table using Spring Boot.
- 🌐 The candidate is aware of the concepts of microservices and the shift from monolithic architectures.
- 📊 The candidate uses Actuator for monitoring and managing applications.
- 📝 The candidate tests applications using JUnit 5.
Q & A
What is the job requirement mentioned in the transcript?
-The job requires a Java developer with a good understanding of Java, Spring Boot, and microservices. Hands-on experience with CI/CD is an added advantage. The candidate should be willing to work in a hybrid model from Bangalore or Chennai.
What is the candidate's current location and are they willing to relocate?
-The candidate is currently in Gorakpur, UP, but is willing to relocate. They have previously lived in Bangalore and will manage the relocation.
What technologies has the candidate worked with in their past projects?
-The candidate has worked with Java, Spring Boot, Hubs framework for the front end, MySQL for the database, and has experience with APIs. They have also used Java 8 features such as Lambda expressions and Stream API.
What is the project methodology used by the candidate's current project?
-The candidate's current project uses the Agile methodology with Sprints lasting 15 days.
What Java version has the candidate used and what features are they familiar with?
-The candidate has used Java 8 and is familiar with Lambda functions, Function Interface, Stream API, and the Optional class.
How does the candidate approach writing code for filtering employees based on location?
-The candidate would use Java to filter the employee list based on the location, specifically filtering for employees from Chennai.
What is the scenario given to the candidate for sorting a list of employees?
-The candidate is asked to sort a list of employees by their names, and if names match, then sort by their age.
Can one functional interface inherit another, according to the candidate?
-Yes, one functional interface can inherit another, but it will have more than one abstract method if it does so.
How does the candidate plan to design an API to get the first five records from an employee table?
-The candidate would create a Spring Boot project, add MySQL driver and Spring Data JPA dependencies, configure the property file for database connection, define the entity class, create a service layer, and use a custom finder method in the repository to fetch the first five records.
What is the difference between a JPA repository and a traditional repository according to the candidate?
-The candidate mentions that JPA repositories provide additional functionality like paging and sorting, which are not available in traditional repositories.
How does the candidate handle different output formats (JSON and XML) for an API?
-The candidate suggests using the @ResponseBody annotation to return the appropriate format, with JSON being the default and XML handled by using a different response body configuration.
How has the candidate used Spring Boot Actuator in their projects?
-The candidate has used Spring Boot Actuator for monitoring and managing the health of their deployed applications, checking for created beans, loggers, and heap usage.
Outlines
👨💻 Java Developer Role Overview and Introduction
In this paragraph, the speaker outlines the job requirement for a Java Developer role. Key skills required include Java, Spring Boot, Microservices, and hands-on experience with CI/CD. The role is hybrid, based in Bangalore or Chennai. The speaker briefly checks the candidate's willingness to relocate, and the candidate confirms their readiness to move from Gorakhpur, Uttar Pradesh.
👨💼 Candidate's Technical Background and Project Experience
The candidate introduces themselves as B. Singh with 4.1 years of experience in IT. They describe working in the banking and healthcare domains with Java, Spring Boot, and MySQL. The candidate details their experience with API support, service logic manipulation, and involvement in development tasks using Java's latest features such as Lambda expressions, Stream API, and Optional classes. They also touch on their involvement in agile methodology, working in 15-day sprints, and using Java 8.
🧑💻 Coding Challenge: Filter and Sort Operations
The interviewer gives the candidate a coding scenario to filter employee ages based on location (Chennai) using Java 8 features. The candidate explains how they would filter the list and extract the relevant ages. They are then asked to sort employees by name, with a secondary sort by age if the names match. The candidate suggests using Comparator, explaining its functionality compared to Comparable, and shares their understanding of functional interfaces such as Predicate, Supplier, and Consumer.
📊 API Design: Fetching Data from Database
The candidate is asked to explain how they would design an API to retrieve the first five records from an employee database. They explain how they would configure the project with necessary dependencies, use JPA Repository, and customize queries if needed. The candidate discusses the use of custom queries and native SQL to retrieve records, with additional discussion on the difference between JPA Repository and CrudRepository. They also briefly touch upon returning data in different formats like JSON and XML.
🛠 Microservices, Monolithic Architecture, and Testing
The candidate discusses microservices, including its advantages over monolithic architecture, such as easier scalability, manageability, and deployment. They explain how services in microservices architecture can be deployed separately, reducing downtime. The candidate also mentions their experience with JUnit 5 for testing service layers and repository methods. Finally, they express their willingness to learn more about microservices despite limited hands-on experience.
Mindmap
Keywords
💡Java
💡Spring Boot
💡Microservices
💡CI/CD
💡Hybrid Model
💡Lambda Functions
💡Stream API
💡Optional Class
💡API Development
💡JUnit
💡Actuator
Highlights
Requirement for a Java developer with expertise in Java Spring and microservices.
Experience with CI/CD is considered an advantage.
The candidate must be willing to work in a hybrid model from Bangalore or Chennai.
Candidate introduces himself as B. Singh with 4.1 years of IT experience.
Worked on banking and healthcare domains, primarily with Java and Spring Boot.
Experience with databases such as MySQL.
Involved in API development and service layer manipulation.
Uses Agile methodology with Sprints typically lasting 15 days.
Java 8 is the primary version used, with features like Lambda functions and Stream API.
Scenario given to write code to filter employees by location and print their ages.
Second scenario involves sorting a list of employees by name and age.
Discussion on functional interfaces like Predicate, Supplier, and Consumer.
Explanation of intermediate and terminal operations in Java Streams.
Project involves writing REST APIs for database communication.
Design approach for an API to get the first five records from an employee table.
Difference between JPA Repository and a traditional Repository.
Handling different output formats (JSON and XML) for API responses.
Use of Actuator for application monitoring and management.
Awareness of microservices architecture and its advantages over monolithic applications.
Testing applications using JUnit 5.
Transcripts
thank you uh could you identify with the
government em yes uh this
one till back it's uh going beyond the
screen till in front of the
camera it should not cover your face it
is covering your face
okay thank you thanks
for identification uh so because uh just
a brief you on the requirement okay it's
again a Java developer Ro uh having a
good understanding on Java springboard
microservices some handson on J cicd
would be an added Advantage okay so this
is a type of uh skill set requir and
person has to be working from Bangalore
or Chennai in an hybrid mod okay okay
okay so I hope you clear with the
requirement uh yes sir so where where
are you based currently uh currently I'm
in my hometown my hometown is gorakpur
up okay so you are working I mean you
are okay to relocate yes yes I will
relocate no problem G uh the at the time
of CC I live in Bangalore so
no I will relocate I will
manage okay so uh can you just brief
about yourself let me know about the
project the technology stack you have
been working on so okay so my name is B
Singh and I have total 4.1 year of
experience in IT background in my first
company intellect design Arena I work
for a banking domain so we have a
product like import LC export LC backto
back LC uh this uh product based on for
the front end we are using hubs
framework internal framework and for the
back end we are using mostly Java and
spring Embassy spring boot mostly I'm
using and for the database we are using
MySQL and my uh recent company I working
for healthcare domain so here also same
we are using spring boot mostly we are
using and some Java code Java we are
using Java new features also we are
using and mostly I involve in the like
API support so whatever the requirement
endm is coming so based on that we are
going to manipulate that service logic
and service layer and give the API
support for that for the marting so
mostly I involve in
like take Development Area so mostly I
work in this framework and that's it
from my
set sorry so in the current project what
is the uh project methodology like are
you using a currently yes we are using
that aile
methodology okay so what are what are
the meetings or how how how what what
duration is your
Sprint so mostly uh in the development
phase or Sprint is 15 days or mix to
nextx 13 days some cases is uh mostly is
a 15 days that is print so whatever we
have so in within the time we are going
to deploy all those code and in the
Sprint
so 15 days is
maximum okay so what is the Java version
you have been using so mostly we are
using uh java8 we are using in my
project so what are the features of
java8 that you worked
on so like if I'm talking about what I'm
using like mostly we are using Lambda
function we are using and function
interface the function manner we are
using and mostly for the data
manipulation or collection object for
the we are using a stream API and so
there are many new features we have
already like optional class mostly we
are using so option class we are using
and Lambda expression we are using
Lambda function also we are using stream
May mostly are
used okay I'll give you a scenario if
you can write a code okay if you if you
can open notepad ID whatever I don't
want you to run it just the logic I want
you to write consider you have an
employee list okay consisting of
employee objects okay uh so employe is
an entity consisting of ID name age
location of the employee okay so you
have to use Java it basically and uh
just
uh print the age of the employees who
are from uh you know Chennai location
maybe okay so we are going to print is
uh based
[Music]
on location based on location like based
on
loc so suppose that we
have so suppose that we have a list of
this
emplo EMP this is a we have a list I
think
so print the Age based on the location
so we need to print the Age based on the
location in the scenario or you can make
it simpler we have to print the ages of
all the employees who are from chenai
location okay
so gu
filter first we need to filter that
location locational
based on that location we need to
[Music]
filter we can pass that one
hello yeah yeah tell
me okay so first we need to filter out
the
object mistake here we need to filter
out and
do location I think good location
[Music]
[Music]
first
this
uh so this way we are going to print
this
one okay the location is CH then you're
collecting the
age okay so this is you get the age okay
now I'll give you one more scenario okay
uh first sort this same list sort this
list by the names of the employees okay
uh for example employee one is vikas uh
staying in Bangalore employee 2 is sha
staying in Mumbai employee ID 3 is
another vas staying in Chennai okay so
the employ ID are different but the
names are same right so sort the
employee list based on the names of the
employees and if names match like one
and three have same names then s by h of
the
employe so first we need to sort based
on the name and then we having the
duplicate
so need to sort by the
age
M so first we need to sorting
so I'm
comparing shorted computer comparing
not
comping can you repeat that scenario
once yeah yeah
yeah the names match s by the
h no first if the first we need to sort
based on that
name and then we need to name match then
only sort
by okay so we are going to
short compor comparing
so name need to start in or ascending or
any reverse
order yeah uh any any ORD fine that you
want to
[Music]
have have
and this one so so just
Computing so just filter this sorting
this I'm not sure we can use equals to
equals to here or not
but so so why are you using a comparator
here and why not a comparable
so if I'm using that so I need to pass
that like object we need to pass o1
comma O2 and then o1 dog name we need to
compare compare two method we can use so
here I'm just passing this compor do
this function I'm directly use by
natural order
or
this this way also we can use compar to
Method we can use like I'm using that
one also
okay so what are some of the other
functional interfaces that you have
used the function interfaces like
predicates we are using predicate
supplier
consumer all this predicate function
interface we are using so only one
abstract method is there and there is no
restriction of static method and default
method so like in predicate we have a
text method and consumer we have a
accept method this U
abstract method we
have okay okay uh moving ahead in this
statement okay for example you consider
this line number five what are the
intermediate and terminal operations
that you
using okay so we have this
filter so filter is the part of
intermediate operation and this collect
also the collect is a part of like
terminal and for each also part of
terminal and the mean Max and so in that
intermediate operation we have reduced
filter flat map map this part of
intermediate this we this
filter in
jaace ined in
jav yes I heard about that M some like
previously we have some enhan in memory
based on that like Palm engine is this
concept is there
permanent so it's introduced like
enhancement is coming so m space
introduced previously a per engine
permanent memory space is there so some
due to the lack of memory issue they are
going to introduce in the metal space
I'm not much more
about more about but I heard about that
space so regarding functional interfaces
that you're mentioning can one
functional interface inherit another
function
interface no see if one functional
interface uh if yeah it can be inherit
but uh that is not part of that function
interface because that uh if other
interface going to extend so so one
abstract met is going to be the coming
from the parent and it we defining so we
have like a normal interface so we can
uh yes we can extend
that okay okay oving to uh
your writing apis and all in your
project currently uh yes for the like
resource uh resource update or delete or
fast like database communication we are
writing Rest API so controller we are
written for rest controller and inside
that we are defining all those method
which are which is going to handle that
a protocol protocol going to
handle can okay
uh okay so I'll give you one scenario I
want you to tell me how will you design
this okay uh consider uh you have a same
employee table if you want to write an
API to get the first five records from
this employee
table okay how how will you go about
implementing this what are the classes
involved how will you connect to the
database I want you to explain me on
that okay so uh firstly whenever uh
suppose mostly I'm using like STS I'm
using so from the spring iner I'm going
to create one project and if I want to
communicate with the database so I need
to add some for starters like for the
database we have MyQ driver and this
dependency we are required MyQ driver
and data GPA this need once the project
is going to create it so first we are
going to configure our property file so
inside that we are configure all the
database related stuff like
spring spring. data source username
password driver name and class name all
those things and once database is
connected then we are going to create
like one structure we are going to
create for the database so for that we
are going to create one uh like classes
inside that we are creating a separate
class and Mark as that class at theate
entity class so we are going to uh
Define classes and whatever the
attribute I'm defining so through that
we are going going to create the
structure of that database so once the
database going to be created So based on
that we are going to write one uh
service layer I'm going to write so in
that service layer we are going to
Define that method that method going to
execute based on the requirement and
fetching the data so for the DB like
fetching the data so we are not directly
we are going to fet the data from the DB
so we are just using the like we are
using data jpa Repository so okay GP
repository I'm using so for that I'm
going to create one repository CL
repository interface extend by the data
data GP repository and then inside if I
extending so we just passing that ID
comma serializable also we can pass that
the name we can pass and then we can use
the Inu method like find by ID find by
name so if you want to like if you uh
what you want to stct the
data no I want I want you to write the
API to get the first P records from
employee
table
okay so then we are writing so we are
writing the service class so find by
find the data like find the users I'm
going to create one uh service layer
creating the one method and then
creating the implementation I give the
implementation for that and what about
the repository of defining so by using
inside that we have custom finder method
also we can Define find my suppose that
if I'm separate if I want to create
separate method and execute some custom
query so I'm just creating like find by
name so sorted name we can that that
type
of no no but in this scenario when I
need the first F
records do you have any custom method
which can be used or any method which
can be used or you need to write a
custom query yeah because like we have
find by ID this type of method we have
sa find by ID so I don't know it's going
to f the
record but we need to write I think
custom query or native query we need to
write in this case so that's why I
thought we need to a custom finder
method we can write and based on that we
query we through that we are going to
fire one query and then we are going to
create the one the rest controller class
and write one method so that method
going to handle the HTTP request from
the front
end so I think this is the so what sort
of query suppose if you want to write
this query in a normal SQL to get the
first how how will you write the query
so select like select employee like
select start from employee and ordered
by descending and then I'm using the
limit 1 to five then it's printing only
the 5 code
M so uh you said you're raising a jpa
repository right so what's the
difference between a jpa and a credit
Repository
yes so this two extra facility we are
getting in GP repository like paging and
shorting so that purpose we are mostly
using I'm not using that shorting and P
and this extra functionality we have in
GP repository rather than
repository okay so now consider you have
written this AP okay and there are
customers are going to call this
APM some of them want an output in Json
format and some of them need an output
in XML format how do we handle
this so I think some in that method
level mostly response body we are using
so procedure equals to some tag we are
using so rather than Json we are stml
object we are going to
WR so
some procedure equals to something that
I'm missing that
name okay okay uh how actuators have you
used actuators anytime in the
project actuator yes once we like
develop our application so once we
deploy that server so we are going to
manage monitoring that application so
that purpose we are going to use the
acuator so yes again we are going to add
one dependency like acuator dependenc
and then based on that we are going to
monitor and check the health of our
application how many the beans is
created that loggers and that Heap and
something so by the actuators we can
manage and monitoring that
application okay so uh so the concern
I'll talk about it are working on
Microsoft I'm not getting
much micros Services I'm not involved in
that so but yes I'm aware of that and
I'm try willing to learn more about the
microservices recently I'm trying to
work on that so I'm aware of that like
what why we are switching monolithic to
micro Services what is the advantage
disadvantage what is the API Gateway
Services what is the advantage or what
is the disadvantage you have in this
monolithic application that's so the
everybody is trying to move to
microservice based market so the the
most disadvantage of Monolithic we are
going to all the services we are binding
at a single places so all the large
application we are not going to break
down that so in the main disadvantage
whenever we are going to do the sort of
short like we are going to do Implement
any particular Services then it's a
minor change then still we are going to
the time of deployment we are going to
deploy all the project so it's time
going to consuming so that that is one
reason and so that's why suppose that we
have a microservice architecture so all
the services work as a different
different microservices so if any
requirement changes or anything happen
in the particular services so we are
just going to uh minor change in that
particular service and deploy separately
them and manage that micros service
separate team or written by the
different different language so
internally we are going to communicate
with different different uh
microservices so it's easy to manage it
easy to deployment in easy to scalable
our project if we follow the
microservices rather
than so um moving to testing part how
how are you testing your
application junit I
use J unit five I use for the whatever
the service layer and we have a
repository like Dow layer we have if I'm
writing one method so that time we need
to write U test cases for that
particular method yeah g 5 I'm used
mostly at the test
تصفح المزيد من مقاطع الفيديو ذات الصلة
java microservice telephonic interview of 10 years experienced
3+ years Java Developer Accenture Interview Experience| Java | Spring Boot | Microservices
TCS Java | Spring Boot | Microservices | 4 Years | Selected | Mock Interview
Caught Cheating - SDE Candidate interview unexpectedly terminated | [Software Engineering Interview]
Capgemini Java Interview 2024 | Java | Spring Boot | Microservices | Database
Java Spring Boot 3 Years Experience Interview
5.0 / 5 (0 votes)