Java Spring Boot Developer
30+ Java Spring Boot Developer Interview Questions and Answers

Asked in Infosys

Q. explain new feature in java (labda, functional interface, default) , what is stream api , filter value not contain null, what is microservice, explain in real time , what is http vs https, inner join , outer jo...
read moreExplanation of Java features, Stream API, microservices, HTTP vs HTTPS, and SQL joins.
Lambda expressions allow for concise syntax to implement functional interfaces.
Stream API provides a way to process collections of objects in a functional style.
Microservices architecture breaks down applications into smaller, independent services.
HTTP is unencrypted protocol, HTTPS is encrypted using SSL/TLS for secure communication.
Inner join combines rows from two tables based on a relate...read more

Asked in TCS

Q. What is the difference between Spring and Spring Boot?
Spring is a framework that provides a comprehensive programming and configuration model for Java applications. Spring Boot is a framework that simplifies the setup and configuration of Spring applications.
Spring is a larger framework that provides various modules for different functionalities like dependency injection, MVC, security, etc.
Spring Boot is an opinionated framework that auto-configures the Spring application with sensible defaults, reducing the need for manual con...read more
Java Spring Boot Developer Interview Questions and Answers for Freshers

Asked in Infosys

Q. What are java8 features? Why string is immutable? Difference between the checked exception and unchecked exception? Difference between throw and throws? Difference between inner class and anonymous class? Inter...
read moreAnswers to common Java Spring Boot Developer interview questions.
Java8 features include lambda expressions, functional interfaces, streams, and default methods.
String is immutable in Java to ensure thread safety and prevent unintended modifications.
Checked exceptions are checked at compile time, while unchecked exceptions are not. Example: IOException vs NullPointerException.
throw is used to explicitly throw an exception, while throws is used to declare that a method may thro...read more

Asked in Deloitte

Q. Why do we have @functionalInterface if we can make any interface a functional interface if it already has one abstract method?
Functional interfaces provide clarity and enforce single abstract method constraint.
Functional interfaces provide clarity to developers by explicitly indicating that the interface is intended to be used as a functional interface.
Using @FunctionalInterface annotation helps enforce the single abstract method constraint, preventing accidental addition of more abstract methods.
It also allows the compiler to perform additional checks to ensure that the interface meets the requirem...read more

Asked in Infosys

Q. How can streams be used to find the person with the maximum age from an array of Person objects, given a Person class?
Use Java Streams to find the person with the maximum age from an array of Person objects efficiently.
1. Define the Person class with an age attribute: `class Person { int age; }`.
2. Create an array of Person objects: `Person[] people = {new Person(25), new Person(30), new Person(22)};`.
3. Use Streams to find the maximum age: `Person oldest = Arrays.stream(people).max(Comparator.comparingInt(Person::getAge)).orElse(null);`.
4. Ensure to handle the case where the array might be ...read more

Asked in Infosys

Q. What can you explain about the Controller in Spring Boot, Dependency Injection, Bean Lifecycle, and Java Persistence API (JPA)?
Overview of Controller, Dependency Injection, Bean Lifecycle, and JPA in Spring Boot.
Controller: Handles HTTP requests and responses, annotated with @Controller or @RestController.
Dependency Injection: A design pattern that allows Spring to manage object creation and dependencies, using @Autowired.
Bean Lifecycle: Involves phases like instantiation, dependency injection, initialization, and destruction, managed by Spring.
JPA: A specification for accessing data in Java, often u...read more
Java Spring Boot Developer Jobs




Asked in Infosys

Q. What is the SOLID principle, and can you explain the concept of a Singleton class and the use of a private constructor within it?
SOLID principles guide software design for better maintainability and scalability. Singleton ensures a single instance of a class.
S: Single Responsibility Principle - A class should have one reason to change.
O: Open/Closed Principle - Software entities should be open for extension but closed for modification.
L: Liskov Substitution Principle - Subtypes must be substitutable for their base types.
I: Interface Segregation Principle - Clients should not be forced to depend on inte...read more

Asked in Infosys

Q. What is the implementation of the Fibonacci Series in Java for generating 'n' terms?
The Fibonacci series is a sequence where each number is the sum of the two preceding ones, starting from 0 and 1.
The Fibonacci series starts with 0 and 1.
Each subsequent number is the sum of the previous two.
Example: For n=5, the series is 0, 1, 1, 2, 3.
A simple implementation can be done using iteration or recursion.
Share interview questions and help millions of jobseekers 🌟

Asked in Infosys

Q. What is the process for retrieving data from a database using a REST API in Spring Boot with Java?
Retrieve data from a database using REST API in Spring Boot involves creating a controller, service, and repository.
1. Create a Spring Boot application with necessary dependencies (Spring Web, Spring Data JPA, etc.).
2. Define an entity class that maps to the database table.
Example: @Entity public class User { @Id private Long id; private String name; }
3. Create a repository interface extending JpaRepository for CRUD operations.
Example: public interface UserRepository extend...read more

Asked in Infosys

Q. What is singleton class? Inheritance, Polymorphism, Annotations in spring boot.
A singleton class is a class that allows only one instance of itself to be created and provides a global point of access to that instance.
Singleton classes are often used in Spring Boot for managing resources such as database connections or thread pools.
In Spring Boot, singleton beans are created by default, meaning that only one instance of a bean is created and shared across the application.
To create a singleton bean in Spring Boot, you can use the @Component annotation or ...read more

Asked in Infosys

Q. Method overriding Method overloading Exception Java 8 Find the 2nd non repeating character from a string Find the sum of square of even numbers
The question covers topics like method overriding, method overloading, exceptions, Java 8 features, and string manipulation.
Method overriding is when a subclass provides a specific implementation of a method that is already provided by its superclass.
Method overloading is when multiple methods have the same name but different parameters.
Exception handling is used to handle errors that occur during the execution of a program.
Java 8 introduced features like lambda expressions, ...read more

Asked in Infosys

Q. What is the difference between a REST controller and a normal controller?
Rest controllers are specifically used for RESTful web services, while normal controllers are used for traditional web applications.
Rest controllers are used to build RESTful web services that can accept and return JSON or XML data.
Normal controllers are used for traditional web applications that render HTML views.
Rest controllers use annotations like @RestController and @RequestMapping to define endpoints.
Normal controllers use annotations like @Controller and @GetMapping to...read more

Asked in Infosys

Q. What is dependency injection, and what are its types?
Dependency injection is a design pattern that allows a class to receive its dependencies from an external source rather than creating them itself.
Promotes loose coupling between classes, enhancing testability and maintainability.
Types of dependency injection include Constructor Injection, Setter Injection, and Interface Injection.
Example of Constructor Injection: A class 'Car' that requires an 'Engine' can receive it through its constructor.
Example of Setter Injection: A clas...read more

Asked in Allstate

Q. What is logging in Spring Boot?
Logging in Spring Boot is a feature that allows developers to track and record events and errors that occur during application runtime.
Spring Boot uses the popular logging framework, Logback, for its logging capabilities.
Developers can configure logging levels and output formats in the application.properties or application.yml file.
Logging can be used to track application performance, debug errors, and monitor user activity.
Spring Boot also provides a convenient way to view a...read more

Asked in Infosys

Q. What is a memory leak and how would you identify one?
Memory leak is a situation where a program uses memory inefficiently, causing memory to be allocated but not released.
Memory leak occurs when a program allocates memory but does not release it after it is no longer needed.
Identifying memory leaks can be done using tools like profilers to analyze memory usage over time.
Common signs of memory leaks include increasing memory usage over time, frequent garbage collection, and application crashes due to out-of-memory errors.

Asked in Deloitte

Q. What is Comparable, and how do you implement it?
Comparable is an interface in Java used for comparing objects and sorting collections.
Comparable interface is used to define a natural ordering of objects.
To implement Comparable, a class must implement the compareTo() method.
Example: Implementing Comparable interface in a class to compare instances based on a specific attribute.

Asked in Infosys

Q. What is abstract class streams static keyword
Abstract classes, streams, and the static keyword are key concepts in Java for structuring code and managing data flow.
Abstract Class: A class that cannot be instantiated and may contain abstract methods (without implementation). Example: `abstract class Animal { abstract void sound(); }`
Streams: A sequence of data elements supporting sequential and parallel aggregate operations. Example: `List<String> names = Arrays.asList('John', 'Jane'); names.stream().filter(name -> name....read more

Asked in Infosys

Q. What are stateless and stateful APIs?
Stateless API does not store client state on the server, while stateful API does.
Stateless API: Each request from client to server must contain all necessary information for the server to fulfill the request. No client state is stored on the server. Example: RESTful APIs.
Stateful API: The server stores client state, which can be accessed by subsequent requests. Example: HTTP sessions.

Asked in Accenture

Q. Write a Java program to implement Run Length Encoding. For example, given the input AABBBCCCC, the output should be 2A3B4C.
Run Length Encoding compresses consecutive characters into counts followed by the character.
Iterate through the string while counting consecutive characters.
When a different character is encountered, append the count and character to the result.
Example: For 'AABBBCCCC', the output is '2A3B4C'.
Edge case: For an empty string, the output should also be an empty string.

Asked in Infosys

Q. Write code to separate a string into a character array.
This code demonstrates how to convert a string into a character array in Java.
Use the `toCharArray()` method: `char[] chars = str.toCharArray();`
Example: `String str = "Hello"; char[] chars = str.toCharArray();`
Iterate through the array: `for (char c : chars) { System.out.println(c); }`
You can also use `String.split()` for separating by delimiters, but it returns a String array.

Asked in Accenture

Q. What is the difference between String and StringBuffer?
String is immutable, String Buffer is mutable.
String is immutable, meaning its value cannot be changed once it is created.
String Buffer is mutable, meaning its value can be changed after it is created.
String is faster and more memory efficient for simple string operations.
String Buffer is slower but more efficient for operations that require frequent modifications.

Asked in Allstate

Q. What is Spring Actuator?
Spring Actuator is a tool that provides endpoints to monitor and manage Spring Boot applications.
Actuator provides health, metrics, info, and other endpoints
It can be used to monitor and manage the application's health and performance
Actuator endpoints can be customized and secured using Spring Security
Examples of endpoints include /health, /metrics, /info, /env, and /shutdown

Asked in Infosys

Q. Write code for reversing a string in Java 8.
Java 8 provides a concise way to reverse a string using streams and collectors.
Use the StringBuilder class: StringBuilder sb = new StringBuilder(originalString); sb.reverse();
Utilize Java 8 Streams: String reversed = originalString.chars().mapToObj(c -> (char) c).reduce("", (s, c) -> c + s);
Another approach is to convert the string to a char array, reverse it, and create a new string: char[] charArray = originalString.toCharArray();

Asked in Accenture

Q. What is the difference between HTTP status 204 and 404?
HTTP status 204 means no content, while 404 means not found.
HTTP status 204 indicates a successful request, but with no content to return.
HTTP status 404 indicates that the requested resource could not be found on the server.
HTTP status 204 is often used for successful DELETE requests where no content needs to be returned.
HTTP status 404 is commonly seen when a user tries to access a non-existent URL.

Asked in Infosys

Q. Explain Spring Security.
Spring Security is a powerful and highly customizable authentication and access-control framework.
Provides authentication and authorization support for web applications
Offers a wide range of security features such as password hashing, CSRF protection, and session management
Can be easily integrated with other Spring frameworks like Spring MVC and Spring Boot
Supports multiple authentication mechanisms such as form-based, basic, and OAuth2
Allows for custom security configuration...read more

Asked in upGrad

Q. Is Java a statically typed language?
Yes, Java is a statically typed language, meaning variable types are known at compile time.
In Java, you must declare the type of a variable when you create it. Example: 'int number = 5;'
Static typing helps catch type-related errors at compile time rather than at runtime.
Java's type system includes primitive types (int, char, etc.) and reference types (objects).
You cannot assign a value of one type to a variable of another type without explicit casting. Example: 'double d = 5;...read more

Asked in Accenture

Q. What are the differences between Spring and Spring Boot?
Spring is a framework for Java development, while Spring Boot simplifies Spring application setup and configuration.
Spring requires extensive configuration, while Spring Boot uses convention over configuration.
Spring Boot includes embedded servers (like Tomcat), eliminating the need for external server setup.
Spring Boot provides starters, which are pre-configured dependencies for common tasks (e.g., spring-boot-starter-web).
Spring applications can be complex and verbose, wher...read more

Asked in Infosys

Q. What is dependency injection?
Dependency injection is a design pattern where the dependencies of a class are provided externally rather than being created within the class itself.
Dependency injection helps in achieving loose coupling between classes.
It allows for easier testing and maintenance of code.
There are three types of dependency injection: constructor injection, setter injection, and interface injection.
Example: In Spring Boot, dependencies are injected using annotations like @Autowired.

Asked in Infosys

Q. What is the difference between Spring Boot and Spring?
Spring is a framework for building Java applications, while Spring Boot is a tool for easily creating stand-alone, production-grade Spring-based applications.
Spring is a framework that provides comprehensive infrastructure support for developing Java applications.
Spring Boot is a tool that simplifies the process of creating and deploying Spring-based applications.
Spring Boot includes embedded servers, which makes it easy to run applications as standalone JAR files.
Spring Boot...read more

Asked in Volkswagen

Q. Explain the use of @Qualifier annotations.
@Qualifier is used in Spring to resolve ambiguity when multiple beans of the same type exist in the application context.
@Qualifier annotation helps in injecting specific beans when multiple candidates are available.
It can be used with @Autowired to specify which bean to inject.
Example: If you have two beans of type 'DataSource', use @Qualifier("myDataSource") to specify which one to use.
It can also be used with constructor injection, setter injection, and method parameters.
Interview Questions of Similar Designations
Interview Experiences of Popular Companies





Top Interview Questions for Java Spring Boot Developer Related Skills



Reviews
Interviews
Salaries
Users

