Java Springboot Question
Java Springboot Question
----------------------------------------------------------
Role played
Projects worked
Explain the project worked - details
How many microservices were there in the project
Was it monolithic to Microservices or new Microservices development?
Details on experience on Monolithic to Microservices migration?
Experience on developing REST API using Java Spring boot.
Basics of Spring and Springboot (e.g. scope of bean, controller classes, service
classes etc)
Java 1.8 – hands-on experience. Knowledge on stream API
If you have 1000 of requests for a single API, what will happen in background?
What is bean scope? What is Singleton ? whats is Circuit breaker pattern.
REST controller is a Sprig bean or not ?
What is the default scope of Spring bean?
What is Lazy loading?
If we have created some bean - written it as lazy loading and I need to use those
beans in my JUNIT. What do I do to initializing the beans?
What annotations you would put ? If my api is calling another API, what I do in
JUNIT to mock it? What expressions you have used ?
What is lambda expression? Why we need anonymous method? Give a use case?
What is a stream?
What is entry set?
Understand how public, private, static methods are used and how they can be called
from each other.
can you call a private method from publec and vice versa?
If you call a static private method from a public method what will happen?
Security on API?
How the token in header would be verified ?
How the header value will be authenticated ?
Difference between an abstract class and an interface?
What is a list and what needs to be done to add objects to a list?
Can you add objects of different types to a a list at the same time?
Were you able to control coding/ development standards? How it was managed/
maintained?
If there is a common functionality across services ...how did you handled it?
What are the artifacts needed for developing a REST API Microservice?
Any exp on JSON/ Yaml/ RAML? How do you create yaml from json or RAML from YAML or
pojo from Json?
What approach you chose when migrated to Microservices and how did you decide there
will be 30-40 microservices?
how did you come up with a solution to connect a downstream system which was
connected by all the services?
How do you manage inter service communication?
For MQ , were the calls Synchronous or Asynchronous
For http based connectivity, what is the way to handle Asynchronous services in
Springboot?
Are there multiple instances for services or just one ?
Any API gateway used?
What kind of coding standards did you set to ensure that standards are followed?
If you received 1000s of request, what would you to ensure that there is no multi-
threading issue occurs
Do you think Synchronization will slow down the throughput?
Anything on throttling ?
For thousand or millin requests how many instances of REST instances will be
created?
How do you handle scaling of the Application @Coding level and @InfraLevel
What is grafana?
What is Prometheus?
Can Prometheus time series data ?
list.stream().filter((e)->e.getAge()>35).forEach(syso(e.getNmae()));
What is a filer?
What is a predicate?
list.stream().filter(e->e.getAge()>35 &&
e.getAge()<45)..forEach(syso(e.getNmae()));
123
456
789
I have random numbers between 1 to 100 and I want to find the occurrence of these
numbers
If I write my own integer class Java and I put it under Java.lang which one would
be loaded first?
How would you take care of the perfoamnce aspect of the microservice?
Java
1) Different ways to sum list of integers using Streams
2) How to identify and handle null pointer exception in java 8. (My answer was
using Optional class)
3) Explain immutable class and write a sample code. Similarly, Example code for
singleton
(Bala added a scenario like what happens if there is a date object in our custom
immutable class, how to copy the value of date object to our custom immutable
class)
4) Features of Java 8
5) Explain try with resources.
6) What is reduce function in Java Streams. Give an example.
7) What are parallel streams? What are its advantages and disadvantages.
8) Explain where you have used method override concept? Can we change the access
modifiers when overriding a method. (Example From Default to public or Public to
private etc)
9) String comparison (with == and equals() method and using new keyword)
10) What is peek () function in Java 8 streams?
11) Can a Optional hold null values? ( Answer is yes, only if create by using
optional.ofNullble() method but the resulting value will be empty optional object)
Spring/Spring Boot
1) What is actuator and why it is used?
2) How exceptions will be handled in Spring boot applications (He is expecting
about global exception handling using @ControllerAdvice)
3) Explain some Design Patterns of Micro service architecture.
4) Explain the communication between microservices (Sync and Async
Communication)
5) Write a sample code to demonstrate a Rest API GET end point.
6) Were do you store your DB credential in your application.
7) How you’ll read the properties values in your application. (How to read
values from application. Properties file from our Java code. Here we can use @Value
annotation approach and we have another class in spring to read values from
properties file. We can explain both)
Example :
/** The reporting service url. */
private static String reportingServiceUrl;
/**
* Sets the reporting service url.
*
* @param reportUrl the new reporting service url
*/
@Value("${reporting-service.url}")
public void setReportingServiceUrl(String reportUrl) {
reportingServiceUrl = reportUrl;
}
JPA/Hibernate
1) What is Spring Data JPA and how will you create a Spring Boot application
that communicates with Data base . (We need to explain the step/ hierarchy of
application)
2) How you’ll do relational mapping. Give and example for Many to One ( What
annotations we need to use and how we will map with example)
SQL
1) What are indexes and their advantages?
2) What is curser? Have you ever worked on them.
Project Related
1) How many Microservices in your previous project
2) Explain basic structure of your previous project.
3) How you have implemented inter service communication (Same as Micro service
communication)
4) How you’ve implemented security in your application
5) Have you ever worked on a production related bug fix. How did you analyse it.
3) String s1="emp";
String s2="emp";
4)can parent method throws exception and child method throws io exception ,is it
valid?
1. what all design patherns do you aware of ? explain factory design pattern ?
2. what is singleton pattern ? singleton vs prototype ? how to write / create
singleton class ? if we extend singletonclass will it create more than one objects?
3. What are rules of method overrding ? he gave scenrio like if we have private
method in parent class and can we make it as public in child class ?
4. what is exception hirarchey / exception classes? types of exception ? which
exception needs to be handled?
5. String s1=smita
s2=smita
Q1 . s1==s2 Answer--->false
Q2. s1==s2
Class A
{
print("A") }
}
class B extends A
{
public B() //constructors
{
print("B");
}
}
what will be the output
Q.1. Class B =new class B();
Answer : A,B
Java- Usage of collections by me , Java thread , child thread and their joining
Mircoservice- types
API definiation
HTTP methods
Implementation of microservice in a business
SOA vs Rest
Security of microservice
7. There is class company with company name ,reg no. Sort arraylist on the basis of
company name using java8 streams.
8. what are get and post methods of http . difference and uses.
9. how to call path variable and query parameter . how to pass in URL .
10. syntax for get method ? how to pass entity , parameters. how to pass username
and password while calling API.
11. what is the annontation used in main class of spring boot application.
12. Rest template is class or interface.?
13. how services are called between two API.
14. what is proxy ?.
15. have you worked in microservices ? Google colud deployements ?
16. is there any limit on number of classes or interfaces can we extends ? what is
that limit ?
How to get object in service class in spring apllication without using autowire
and construction approach?
How to add headers in resttemplate and authentication and authorizarion (differnt
ways).
How to externalize your service and differnt ways .
loadbalace in micro service.
checked and unchecked exception and how to avoid null pointer exception .
Distributed application architectures and design patterns .
https://www.javaguides.net/2023/07/spring-boot-interview-questions.html
https://www.javaguides.net/2018/11/spring-boot-interview-questions-and-answers.html