Senior Java Developer

400+ Senior Java Developer Interview Questions and Answers

Updated 4 Jul 2025
search-icon

Asked in Wipro

4d ago

Q. How do you allocate heap memory to the JVM, and what values do you pass?

Ans.

To accumulate heap to the JVM, specify the initial and maximum heap size using -Xms and -Xmx flags respectively.

  • Use -Xms flag to specify the initial heap size, e.g. -Xms512m for 512 MB.

  • Use -Xmx flag to specify the maximum heap size, e.g. -Xmx1024m for 1 GB.

  • Example: java -Xms512m -Xmx1024m YourClassName

Asked in HCLTech

1d ago

Q. Draw a low-level design for implementing a 'notify me' feature when an item is back in stock in an e-commerce application.

Ans.

Implementation of 'notify me if item is back in stock' feature in an ecommerce application

  • Create a database table to store user notifications for out-of-stock items

  • Implement a service to check item availability and send notifications to subscribed users

  • Provide a user interface for users to subscribe to notifications for specific items

Asked in DataMetica

2w ago

Q. 1.Calculate age without without using any inbuilt function 2.Department wise highest salary 3.Factorial number

Ans.

Answering interview questions for Senior Java Developer

  • To calculate age, subtract birth year from current year

  • To find department wise highest salary, group by department and find max salary

  • To find factorial number, use a loop to multiply numbers from 1 to n

5d ago

Q. with stream API, find employees with salary greater than 50000 and arrange it in descending order. using streams find average of numbers in a list

Ans.

Use stream API to filter employees by salary and find average of numbers in a list.

  • Filter employees with salary > 50000 and sort in descending order using stream API

  • Calculate average of numbers in a list using stream API

Are these interview questions helpful?
1w ago

Q. Given an array, find all the numbers whose sum is 11 using streams only.

Ans.

Use Java Streams to find pairs in an array that sum to 11.

  • Use IntStream.range to iterate through the array indices.

  • For each element, check if there's a complement (11 - current element) in the array.

  • Use a Set to store seen numbers for efficient lookup.

  • Example: For array [1, 10, 2, 9, 3, 8], pairs are (10, 1), (9, 2), (8, 3).

Asked in Infosys

3d ago

Q. Can you perform all three operations (Get, Supply, Delete data) using a single API endpoint?

Ans.

Yes, by implementing a RESTful API with different HTTP methods for each operation.

  • Implement a RESTful API with different endpoints for each operation: GET for retrieving data, POST for supplying data, and DELETE for deleting data.

  • For example, GET /data to retrieve data, POST /data to supply data, and DELETE /data/{id} to delete data by ID.

  • Use proper HTTP methods and status codes to handle each operation effectively.

Senior Java Developer Jobs

SAP India Pvt.Ltd logo
Senior Java Developer 8-13 years
SAP India Pvt.Ltd
4.2
₹ 15 L/yr - ₹ 36 L/yr
(AmbitionBox estimate)
Bangalore / Bengaluru
TekWissen logo
Senior Java Developer 9-12 years
TekWissen
4.8
Chennai
Genpact logo
Senior Java Developer 7-10 years
Genpact
3.8
₹ 5 L/yr - ₹ 16 L/yr
Bangalore / Bengaluru

Asked in Ericsson

1w ago

Q. What are the different techniques to inject a bean into an application context?

Ans.

Different techniques for injecting beans in application context

  • Constructor Injection

  • Setter Injection

  • Field Injection

  • Method Injection

1w ago

Q. What is the difference between ArrayList and LinkedList?

Ans.

ArrayList is implemented as a resizable array while LinkedList is implemented as a doubly linked list.

  • ArrayList provides constant time for accessing elements while LinkedList provides constant time for adding or removing elements.

  • ArrayList is better for storing and accessing data while LinkedList is better for manipulating data.

  • ArrayList is faster for iterating through elements while LinkedList is faster for adding or removing elements in the middle of the list.

Share interview questions and help millions of jobseekers 🌟

man-with-laptop

Asked in Walmart

3d ago

Q. What are the common issues faced while deploying a service to AWS?

Ans.

Common issues faced while deploying a service to AWS

  • Configuration errors leading to service downtime

  • Security misconfigurations exposing sensitive data

  • Performance issues due to improper resource allocation

  • Network connectivity problems affecting service availability

  • Lack of monitoring and logging causing difficulties in troubleshooting

  • Incompatibility issues with other AWS services or third-party integrations

1w ago

Q. What is the difference between get and load in Hibernate?

Ans.

get() method returns null if object is not found in database, while load() method throws ObjectNotFoundException.

  • get() method is eager loading while load() method is lazy loading.

  • get() method returns a fully initialized object while load() method returns a proxy object.

  • get() method is slower than load() method as it hits the database immediately.

  • load() method is faster than get() method as it returns a proxy object and hits the database only when required.

Asked in Caspex Corp

2w ago

Q. Suppose your application experiences performance issues due to inefficient database queries and data access patterns. How would you analyze the database schema and query execution to identify performance bottle...

read more
Ans.

Analyzing database schema and query execution to identify performance issues

  • Review database schema for normalization and indexing

  • Analyze query execution plans for inefficiencies

  • Consider optimizing data access patterns and query structure

  • Use database profiling tools to identify bottlenecks

  • Implement caching mechanisms for frequently accessed data

Asked in Caspex Corp

2w ago

Q. How do you enable debugging logs in a Spring Boot application?

Ans.

Enable debugging log in Spring Boot application

  • Add 'logging.level.root=DEBUG' in application.properties file

  • Use '@Slf4j' annotation in the Java class to enable logging

  • Set 'logging.level.org.springframework=DEBUG' for Spring framework debugging

Asked in Saviynt

2w ago

Q. Implement a custom HashMap, including efficient code to search for a key-value pair within a composite object (e.g., object within an object within a main object).

Ans.

Implement a custom HashMap to efficiently search for a key value pair of a composite object.

  • Create a custom HashMap class with methods for adding key value pairs and searching for a specific key.

  • Implement a hash function to calculate the index of the key in the HashMap array.

  • For composite objects, override the hashCode and equals methods to ensure proper comparison and retrieval.

Q. In a microservice architecture, is it better to use multiple databases or a single database? Explain your reasoning.

Ans.

Choosing between multiple databases or a single database in microservices depends on scalability, data isolation, and complexity.

  • Microservices with multiple databases allow for data isolation, enabling teams to choose the best database for their service's needs.

  • For example, a service handling user profiles might use a NoSQL database for flexibility, while a financial service might use a relational database for ACID compliance.

  • Using a single database can simplify data manageme...read more

Asked in Infosys

4d ago

Q. What is the difference between Spring Boot and Spring?

Ans.

Spring is a framework for building Java applications, while Spring Boot is a tool that simplifies the setup and configuration of Spring applications.

  • Spring is a comprehensive framework that provides support for various functionalities like dependency injection, aspect-oriented programming, and more.

  • Spring Boot is an opinionated tool that simplifies the setup and configuration of Spring applications by providing defaults and auto-configuration.

  • Spring Boot includes embedded ser...read more

Asked in TCS

3d ago

Q. Java 8 features and stream api example of distinct element in a list

Ans.

Example of using Java 8 features and stream api to get distinct elements in a list.

  • Use the distinct() method of the Stream interface to get distinct elements in a list.

  • The distinct() method returns a stream consisting of the distinct elements of the original stream.

  • Example: List list = Arrays.asList("apple", "banana", "apple", "orange"); list.stream().distinct().forEach(System.out::println);

  • Output: apple banana orange

Asked in Infosys

2w ago

Q. What are the Spring Boot annotations you commonly use?

Ans.

Commonly used Spring Boot annotations include @RestController, @Autowired, @RequestMapping, @Service, @Component, @Repository.

  • @RestController - Used to define RESTful web services.

  • @Autowired - Used for automatic dependency injection.

  • @RequestMapping - Used to map web requests to specific handler methods.

  • @Service - Used to indicate that a class is a service component.

  • @Component - Used to indicate that a class is a Spring component.

  • @Repository - Used to indicate that a class is ...read more

Asked in Capgemini

1d ago

Q. What are the advantages of Spring Boot over Spring?

Ans.

Spring Boot simplifies the development of Spring applications by providing out-of-the-box configurations and reducing boilerplate code.

  • Spring Boot provides a quick and easy way to set up a Spring application with minimal configuration.

  • It includes embedded servers like Tomcat, Jetty, or Undertow, eliminating the need for deploying WAR files.

  • Auto-configuration feature in Spring Boot automatically configures the application based on dependencies in the classpath.

  • Spring Boot Actu...read more

Asked in EPAM Systems

2w ago

Q. What other principles, apart from SOLID, promote best coding practices?

Ans.

Other principles for best coding practices include DRY, KISS, YAGNI, and design patterns.

  • DRY (Don't Repeat Yourself) - Avoid duplicating code by creating reusable functions or classes.

  • KISS (Keep It Simple, Stupid) - Write simple and easy-to-understand code rather than overcomplicating it.

  • YAGNI (You Aren't Gonna Need It) - Only implement functionality that is needed at the present moment, avoiding unnecessary features.

  • Design Patterns - Follow established design patterns like S...read more

Asked in Infosys

2w ago

Q. what about concurrent HashMap? spring framework IOC And DI

Ans.

ConcurrentHashMap is a thread-safe implementation of the Map interface in Java.

  • ConcurrentHashMap allows multiple threads to read and write to the map concurrently without the need for external synchronization.

  • It is part of the java.util.concurrent package and provides better performance in multi-threaded environments compared to synchronized HashMap.

  • Spring framework supports the use of ConcurrentHashMap for managing beans in a concurrent environment.

  • Inversion of Control (IoC)...read more

Asked in Caspex Corp

1w ago

Q. What is the difference between Monolithic SOA and Microservices architecture?

Ans.

Monolithic SOE is a single large application while Microservices architecture breaks down the application into smaller, independent services.

  • Monolithic SOE is a single, self-contained application where all components are tightly coupled.

  • Microservices architecture breaks down the application into smaller, independent services that communicate through APIs.

  • Monolithic SOE is easier to develop and test but can be harder to scale and maintain.

  • Microservices architecture allows for ...read more

Asked in Magic Edtech

1w ago

Q. Describe a situation where you were unable to implement a custom MongoDB query at the repository layer.

Ans.

Creating custom MongoDB queries in the repository layer is essential for efficient data retrieval and manipulation.

  • Use MongoTemplate for custom queries: Example: mongoTemplate.find(query, YourEntity.class).

  • Utilize Query and Criteria classes to build dynamic queries: Example: Query query = new Query(Criteria.where('field').is(value)).

  • Implement custom repository interfaces for complex queries: Example: public interface YourRepository extends MongoRepository<YourEntity, String>,...read more

2w ago

Q. Write a Java program to print even numbers using one thread and odd numbers using another thread.

Ans.

Program to print even and odd numbers using two threads in Java

  • Create two threads, one for even numbers and one for odd numbers

  • Use a loop to generate numbers and check if they are even or odd

  • Print the numbers using the respective threads

  • Use synchronization to ensure alternate printing of even and odd numbers

Q. Write a function that removes characters before a '#' symbol based on the number of '#' symbols. For example, 'abc#d' should become 'abcd', and 'abc##d' should become 'ad'.

Ans.

Write code to remove number character before hash based on count of hash

  • Count the number of hashes in the input string

  • Loop through the string and remove the character before the hash based on the count of hashes

  • Return the modified string

Asked in Altimetrik

6d ago

Q. Can you explain the Java design patterns that you utilized in your project?

Ans.

I utilized several design patterns in my projects to enhance code maintainability and scalability.

  • Singleton Pattern: Ensured a single instance of a configuration manager throughout the application.

  • Factory Pattern: Used to create different types of user objects based on user roles, promoting loose coupling.

  • Observer Pattern: Implemented for event handling, allowing multiple components to react to changes in the state of an object.

  • Strategy Pattern: Employed to define a family of...read more

2w ago

Q. HOW TO CREATE OUR OWN IMMUTABLE CLASS? WHY IMMUTABLE CLASS

Ans.

Immutable classes in Java are classes whose objects cannot be modified once they are created.

  • Make the class final to prevent inheritance

  • Make all fields private and final

  • Do not provide setter methods for fields

  • Ensure that any mutable objects within the class are also immutable

2w ago

Q. In which situation do we use @Primary and @Qualifier?

Ans.

Use @Primary to specify a primary bean when multiple beans of the same type are present. Use @Qualifier to specify a specific bean when multiple beans of the same type are present.

  • Use @Primary to indicate the primary bean to be used when multiple beans of the same type are present in the Spring application context.

  • Use @Qualifier along with @Autowired to specify a specific bean to be injected when multiple beans of the same type are present.

  • Example: @Primary annotation can be ...read more

2w ago

Q. What is the difference between composition and aggregation?

Ans.

Composition is a strong relationship where the child object cannot exist independently of the parent object, while aggregation is a weak relationship where the child object can exist independently.

  • Composition is a 'has-a' relationship, where the child object is a part of the parent object.

  • Aggregation is a 'has-a' relationship, where the child object is not a part of the parent object.

  • In composition, the child object is created and destroyed along with the parent object.

  • In agg...read more

Asked in Coforge

1w ago

Q. Different exceptions in Spring Boot

Ans.

Spring Boot has various exceptions for different scenarios.

  • DataAccessException - for database access errors

  • HttpMessageNotReadableException - for errors in HTTP message conversion

  • MethodArgumentNotValidException - for validation errors in request parameters

  • NoSuchBeanDefinitionException - for errors in bean configuration

  • UnauthorizedException - for authentication and authorization errors

Asked in Birbal AI

2w ago

Q. How do you optimize your database when handling large data?

Ans.

Optimizing database for handling large data involves indexing, partitioning, denormalization, and using appropriate data types.

  • Use indexing on frequently queried columns to improve search performance.

  • Partition large tables to distribute data across multiple storage devices for faster access.

  • Denormalize data by reducing the number of joins needed for queries.

  • Use appropriate data types to minimize storage space and improve query performance.

Previous
1
2
3
4
5
6
7
Next

Interview Experiences of Popular Companies

TCS Logo
3.6
 • 11.1k Interviews
Infosys Logo
3.6
 • 7.9k Interviews
Wipro Logo
3.7
 • 6.1k Interviews
Cognizant Logo
3.7
 • 5.9k Interviews
Capgemini Logo
3.7
 • 5.1k Interviews
View all
interview tips and stories logo
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories

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

Senior Java Developer Interview Questions
Share an Interview
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits