Backend Java Developer
30+ Backend Java Developer Interview Questions and Answers

Asked in HCLTech

Q. What is the program to filter employees who have a salary greater than 40,000 from the employee list?
This program filters employees with a salary greater than 40,000 from a list, showcasing Java's collection framework capabilities.
Use of Streams: Java 8 introduced streams, which allow for functional-style operations on collections, making filtering straightforward.
Example Code: List<Employee> highEarners = employees.stream().filter(e -> e.getSalary() > 40000).collect(Collectors.toList());
Lambda Expressions: The filter method utilizes lambda expressions for concise and readab...read more

Asked in NielsenIQ

Q. Given a list of strings containing names, return a map where the key is the name and the value is the number of vowels in the name, using only the Java Stream API.
Use Java Stream API to create a map of names and their corresponding vowel counts.
Use Stream.of() to create a stream from the array of names.
Map each name to its vowel count using a custom method.
Collect the results into a Map using Collectors.toMap().
Example: For names ['Alice', 'Bob'], the output would be {'Alice': 3, 'Bob': 1}.
Backend Java Developer Interview Questions and Answers for Freshers

Asked in Zensar Technologies

Q. Take a list and find the list containing prime numbers in list, Find the highest salary of employees using streams and also basic SQL queries on joins
Use Java streams to filter prime numbers from a list, find highest employee salary, and demonstrate basic SQL joins.
Use Java streams to filter prime numbers from the list
Use streams to find the highest salary of employees
Demonstrate basic SQL queries for joins

Asked in triSys IT Services

Q. How would you estimate the number of leaves on all the trees in a given area?
Counting leaves on trees can be simplified using algorithms and data structures for efficiency.
Use a recursive function to traverse the tree structure and count leaves.
Implement a depth-first search (DFS) or breadth-first search (BFS) algorithm.
For large trees, consider parallel processing to speed up counting.
Example: In a binary tree, count leaves by checking if a node has no children.

Asked in Aurionpro Solutions

Q. What is a REST API, and what are the functions of the PUT and POST methods?
A REST API is an architectural style for designing networked applications using HTTP requests to access and manipulate data.
Stateless Communication: REST APIs operate over HTTP and are stateless, meaning each request from a client contains all the information needed to process it.
Resource-Based: REST APIs use resources identified by URIs, allowing clients to interact with data entities through standard HTTP methods.
PUT Method: The PUT method is used to update an existing reso...read more

Asked in Aurionpro Solutions

Q. What is multithreading, and how does it contribute to solving problems in Java programming?
Multithreading in Java allows concurrent execution of tasks, improving performance and resource utilization in applications.
Concurrency: Multithreading enables multiple threads to run simultaneously, allowing for better CPU utilization and faster execution of tasks.
Responsiveness: In GUI applications, multithreading keeps the interface responsive by performing background tasks without freezing the UI.
Resource Sharing: Threads within the same process share memory and resources...read more
Backend Java Developer Jobs




Asked in Aurionpro Solutions

Q. What is the SQL query to find the second highest salary from the given data?
To find the second highest salary, we can use SQL queries that utilize subqueries or the DISTINCT keyword.
Using DISTINCT: SELECT DISTINCT salary FROM employees ORDER BY salary DESC LIMIT 1 OFFSET 1; This retrieves the second highest salary.
Using Subquery: SELECT MAX(salary) FROM employees WHERE salary < (SELECT MAX(salary) FROM employees); This finds the maximum salary less than the highest.
Using ROW_NUMBER: SELECT salary FROM (SELECT salary, ROW_NUMBER() OVER (ORDER BY salar...read more
Asked in Kinfotech

Q. What are JDK, JRE & JVM? Signify public static void main (String [] args). Difference between ArrayList and LinkedList?
JDK is Java Development Kit, JRE is Java Runtime Environment, and JVM is Java Virtual Machine. public static void main (String [] args) is the entry point of a Java program. ArrayList and LinkedList are both implementations of the List interface in Java, but ArrayList uses a dynamic array for storing elements while LinkedList uses a doubly linked list.
JDK (Java Development Kit) is a software development kit used for developing Java applications.
JRE (Java Runtime Environment) ...read more
Share interview questions and help millions of jobseekers 🌟

Asked in KPMG India

Q. What is TreeMap, and can we insert null values into it?
TreeMap is a NavigableMap implementation that stores key-value pairs in a sorted order based on keys.
TreeMap is part of the Java Collections Framework.
It implements the Map interface and is sorted according to the natural ordering of its keys.
Null keys are not allowed; however, null values can be inserted.
Example: TreeMap<String, Integer> map = new TreeMap<>(); map.put('A', 1); map.put('B', null); // valid
It provides methods for navigation like lowerKey, higherKey, etc.

Asked in TCS

Q. Can we create a static method or variable inside a static main() method?
No, static methods or variables cannot be created inside static main() method.
Static methods or variables cannot be created inside another static method.
Static methods or variables can only be created at the class level, outside of any method.
Example: public class MyClass { static int myVariable = 10; }
Asked in Kinfotech

Q. Advantages of Spring Boot framework? Annotations in Spring or Spring Boot? What are Primary key and foreign key in SQL? What is @Qualofier in Spring Boot?
Spring Boot framework provides rapid development, easy configuration, and built-in features. Annotations simplify development. Primary key uniquely identifies a record in a table, foreign key establishes a relationship between tables. @Qualifier in Spring Boot is used to specify which bean to autowire.
Spring Boot offers rapid development, easy configuration, and built-in features like embedded servers.
Annotations in Spring or Spring Boot simplify development by reducing boile...read more

Asked in KPMG India

Q. Given an array of integers, push all zeroes to the end of the array while maintaining the original order. The time complexity should be O(n) and the space complexity should be O(1).
Rearrange an array to move all zeroes to the end while maintaining the order of non-zero elements.
Use two pointers: one for iterating through the array and another for tracking the position to place non-zero elements.
Iterate through the array, and for each non-zero element, place it at the 'write' pointer's position and increment the pointer.
After processing all elements, fill the remaining positions in the array with zeroes.
Example: For input [0, 1, 0, 3, 12], output should ...read more

Asked in TCS

Q. What are the different types of memory in Java, and where are objects stored?
Java memory types and where objects are stored
Java memory consists of stack and heap
Primitive data types are stored in stack
Objects and arrays are stored in heap
References to objects are stored in stack
Example: int num = 5; // num is stored in stack, value 5 is stored in stack
Example: String str = new String(); // str reference is stored in stack, actual String object is stored in heap

Asked in TCS

Q. What does idempotent mean in the context of PATCH and PUT requests?
Idempotent term in patch and put means that multiple identical requests have the same effect as a single request.
Idempotent means that the result of a successful request is the same regardless of how many times it is repeated.
In PATCH and PUT requests, idempotent means that sending the same request multiple times will not have any additional side effects.
For example, if a PATCH request updates a resource with specific data, sending the same PATCH request multiple times will n...read more
Asked in Adansa Solutions

Q. What is JVM ? What is JRE ? What is Multithreading ? JDBC Loop
JVM is a virtual machine that executes Java bytecode. JRE is a runtime environment for Java programs. Multithreading is the ability of a program to execute multiple threads concurrently. JDBC is a Java API for connecting to databases. Loop is a control structure that allows a program to repeat a set of instructions.
JVM executes Java bytecode
JRE provides a runtime environment for Java programs
Multithreading allows for concurrent execution of threads
JDBC is used for connecting ...read more

Asked in KPMG India

Q. What happens when you override static methods?
Overriding static methods in Java does not behave like instance method overriding; it is based on the reference type, not the object type.
Static methods belong to the class, not instances, so they cannot be overridden in the same way as instance methods.
If a subclass defines a static method with the same name and parameters as a static method in the superclass, it hides the superclass method.
Example: If class A has a static method 'static void display()' and class B extends A...read more

Asked in American Express

Q. What is the difference between a query parameter and a path parameter in Spring Boot?
Query param is used to pass parameters in the URL query string, while path param is used to define parameters in the URL path itself.
Query param is specified after the '?' in the URL, like '?param=value'
Path param is specified in the URL path itself, like '/{param}'
Query params are optional and can be used for filtering or sorting data
Path params are used to define variables in the URL path, like IDs or names
Asked in FirstRand Services

Q. What is the internal working of HashMap?
HashMap is a data structure that stores key-value pairs and uses hashing to efficiently retrieve values based on keys.
HashMap internally uses an array of linked lists to store key-value pairs.
When a key-value pair is added, the key is hashed to determine the index in the array where the pair will be stored.
If multiple keys hash to the same index, a linked list is used to handle collisions.
Retrieving a value involves hashing the key to find the index and then traversing the li...read more

Asked in HCLTech

Q. Write a Java program to find the student with the second highest rank in a list of students.
This Java program identifies the student with the second highest rank from a list of students based on their scores.
Data Structure: Use an array or list to store student names and their corresponding ranks or scores.
Sorting: Sort the list of students based on their ranks in descending order to easily access the second highest.
Unique Ranks: Ensure that the ranks are unique; if not, handle duplicates appropriately.
Example: For students with ranks [1, 3, 2, 4], the second highes...read more

Asked in BharatPe

Q. Describe a system design for handling notifications across different systems.
Design a notification system that efficiently delivers messages across various platforms and devices.
Use a message broker (e.g., RabbitMQ, Kafka) for decoupling services.
Implement a REST API for sending notifications.
Support multiple channels: email, SMS, push notifications.
Consider user preferences for notification types and timings.
Ensure scalability by using microservices architecture.

Asked in IBM

Q. How would you create a custom exception?
Custom exceptions can be created by extending the Exception class in Java.
Create a new class that extends the Exception class
Override the constructors to provide custom messages and error codes
Throw the custom exception using the 'throw' keyword

Asked in TCS

Q. What are the differences between HashMap in Java 7 and Java 8?
Java 8 introduced new methods for HashMap such as forEach, compute, merge, etc.
Java 8 introduced new methods like forEach, compute, merge for HashMap operations
Java 8 allows using lambda expressions for iterating over HashMap entries
Java 8 introduced default methods in Map interface for HashMap

Asked in Infosys

Q. What is the difference between an abstract class and an interface?
Abstract class can have both abstract and non-abstract methods, while interface can only have abstract methods.
Abstract class can have constructors, fields, and methods, while interface cannot have any of these.
A class can extend only one abstract class, but can implement multiple interfaces.
Abstract classes are used to provide a common base for subclasses, while interfaces are used to define a contract for classes to implement.
Example: Abstract class 'Animal' with abstract m...read more

Asked in KPMG India

Q. What is LinkedHashMap?
LinkedHashMap is a Java collection that maintains insertion order while providing fast access and retrieval of key-value pairs.
Maintains a doubly-linked list of entries to preserve insertion order.
Allows null values and one null key.
Provides O(1) time complexity for basic operations like get() and put().
Example: LinkedHashMap<String, Integer> map = new LinkedHashMap<>();
Useful for caching and maintaining order in data processing.

Asked in TCS

Q. What is the difference between an array and an ArrayList?
Arrays have fixed size, while ArrayLists can dynamically resize. ArrayLists are part of Java Collections framework.
Arrays have a fixed size, while ArrayLists can dynamically resize.
Arrays can hold primitive data types and objects, while ArrayLists can only hold objects.
Arrays use square brackets [] for declaration, while ArrayLists use angle brackets <>.
Arrays are faster than ArrayLists for accessing elements directly by index.
Example: String[] names = new String[5]; ArrayLis...read more

Asked in Arcesium

Q. Given an unsorted array of integers, find the smallest missing positive integer.
Find the smallest integer in an unsorted array.
Iterate through the array and keep track of the smallest integer found so far.
Use a for loop or a stream to iterate through the array.
If the array is empty, return null or throw an exception.
If the array contains only one element, return that element.

Asked in NoBroker

Q. How do you verify whether a list is a palindrome?
A palindrome list is a list that reads the same backward as forward.
Traverse the list and store the elements in an array
Compare the first element with the last element, second with second last and so on
If all elements match, then the list is a palindrome

Asked in TCS

Q. What is polymorphism?
Polymorphism is the ability of a single function or method to operate on different types of data.
Polymorphism allows objects of different classes to be treated as objects of a common superclass.
There are two types of polymorphism: compile-time (method overloading) and runtime (method overriding).
Example: Inheritance in Java allows a subclass to override a method of its superclass, exhibiting polymorphic behavior.

Asked in IBM

Q. What is a profile in Spring Boot?
Profile in Spring Boot is a set of configurations that can be used to customize the behavior of an application.
Profiles allow developers to define different configurations for different environments (e.g. development, testing, production).
Profiles can be activated using the 'spring.profiles.active' property in the application.properties file.
Profiles can be used to specify different database connections, logging levels, or other settings based on the environment.
Example: 'app...read more

Asked in TCS

Q. Does a hash map store unique names?
Yes, hash map stores unique keys.
Hash map in Java does not allow duplicate keys. If you try to insert a duplicate key, it will replace the existing value with the new one.
However, hash map allows duplicate values.
Example: HashMap<String, Integer> map = new HashMap<>(); map.put("John", 25); map.put("Jane", 30); map.put("John", 35); // 'John' key will now have value 35.
Interview Questions of Similar Designations
Interview Experiences of Popular Companies





Top Interview Questions for Backend Java Developer Related Skills

Calculate your in-hand salary
Confused about how your in-hand salary is calculated? Enter your annual salary (CTC) and get your in-hand salary


Reviews
Interviews
Salaries
Users

