Top 250 Java Interview Questions and Answers

Updated 15 Jul 2025

1w ago

Q. Classloaders in java

Ans.

Classloaders are responsible for loading classes into the JVM at runtime.

  • Java has three built-in classloaders: bootstrap, extension, and system.

  • Custom classloaders can be created to load classes from non-standard sources.

  • Classloaders follow a delegat...read more

Q. Stream and collection api usage

Ans.

Stream and collection api usage involves manipulating data using streams and collections in Java.

  • Stream API provides a way to process collections of objects in a functional way.

  • Collection API provides data structures to store and manipulate groups of...read more

2w ago

Q. Objects in java 8

Ans.

Java 8 introduced the concept of functional programming with the addition of lambda expressions and streams.

  • Lambda expressions allow for concise code and easier parallel programming.

  • Streams provide a way to work with collections of objects in a funct...read more

Asked in LTIMindtree

1w ago

Q. java 8 improvements

Ans.

Java 8 introduced several improvements including lambda expressions, functional interfaces, streams, and default methods.

  • Lambda expressions allow for more concise code and easier parallel programming.

  • Functional interfaces enable the use of lambda exp...read more

Are these interview questions helpful?

Asked in Capgemini

2w ago

Q. Is Java platform-independent, and if so, why?

Ans.

Yes, Java is platform-independent because of its 'write once, run anywhere' principle.

  • Java programs are compiled into bytecode, which can be executed on any platform with a Java Virtual Machine (JVM).

  • The JVM acts as an interpreter, translating the by...read more

2w ago

Q. Can we use a controller annotation instead of a service annotation?

Ans.

No, controller and service annotations serve different purposes in a software application.

  • Controller annotations are used to define the entry points for incoming requests and map them to specific methods in a controller class.

  • Service annotations are ...read more

Share interview questions and help millions of jobseekers 🌟
man with laptop

Asked in Ericsson

2d 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

2w ago

Q. Do you have any knowledge of software such as Java or Python?

Ans.

Yes, I have knowledge of both Java and Python.

  • I have experience in developing robotics applications using Java and Python.

  • I am familiar with object-oriented programming concepts in both languages.

  • I have worked on projects involving robotics simulatio...read more

Q. What are some methods in the Executor framework?

Ans.

The Executor framework in Java provides a high-level API for managing and controlling thread execution.

  • Executor: The simplest interface for executing tasks asynchronously.

  • ExecutorService: Extends Executor, provides methods for managing termination an...read more

Q. multithreading in spring boot

Ans.

Multithreading in Spring Boot allows for concurrent execution of tasks, improving performance and responsiveness.

  • Spring Boot provides support for multithreading through the use of @Async annotation.

  • By annotating a method with @Async, it will be execu...read more

Java Jobs

Red Hat India Pvt Ltd logo
Senior Software Engineer - Full Stack 6-11 years
Red Hat India Pvt Ltd
4.3
₹ 19 L/yr - ₹ 33 L/yr
(AmbitionBox estimate)
Bangalore / Bengaluru
Sodexo Food Solutions India Pvt. Ltd.ces logo
OFFICE BOY 3-5 years
Sodexo Food Solutions India Pvt. Ltd.ces
4.1
Nellore
Equitas Small Finance Bank Ltd logo
Relationship Manager - MF Collections 4-6 years
Equitas Small Finance Bank Ltd
4.4
₹ 2 L/yr - ₹ 7 L/yr
(AmbitionBox estimate)
Karnal

Asked in Rackspace and 2 others

2w ago

Q. What is C++ Java

Ans.

C++ and Java are programming languages used for software development.

  • C++ is a high-performance language used for system programming, game development, and other performance-critical applications.

  • Java is an object-oriented language used for developing...read more

Asked in EPAM Systems

1w ago

Q. What features were introduced in Java 8?

Ans.

Java 8 introduced features like lambda expressions, functional interfaces, streams, and default methods.

  • Lambda expressions allow you to pass functionality as an argument to a method.

  • Functional interfaces have a single abstract method and can be used ...read more

1w ago

Q. Tell me about CompletableFuture.

Ans.

CompletableFuture is a class introduced in Java 8 to represent a future result of an asynchronous computation.

  • CompletableFuture can be used to perform tasks asynchronously and then combine their results.

  • It supports chaining of multiple asynchronous o...read more

Asked in Infogain

2w ago

Q. What is the difference between @Controller and @RestController annotations?

Ans.

The @Controller annotation is used to create a controller class in Spring MVC, while @RestController is used to create RESTful web services.

  • The @Controller annotation is used to create a controller class in Spring MVC, which is used to handle traditi...read more

Q. What is the use of a functional interface?

Ans.

Functional interfaces are interfaces with a single abstract method, used in Java to enable lambda expressions.

  • Functional interfaces allow lambda expressions to be used as instances of the interface.

  • They provide a way to implement functional programmi...read more

Asked in Capgemini

2w ago

Q. How do you find characters using the Stream API?

Ans.

Using Java Stream API to find characters in a string efficiently and concisely.

  • Streams can be created from a string using `chars()` method: `String str = "hello"; str.chars()`.

  • To filter specific characters, use `filter()`: `str.chars().filter(c -> c ...read more

1w ago

Q. What are the commonly used functional interfaces in your application?

Ans.

Commonly used functional interfaces include Predicate, Consumer, Supplier, and Function.

  • Predicate: used for boolean-valued functions of one argument.

  • Consumer: used for operations that take in one argument and return no result.

  • Supplier: used for opera...read more

Q. Frame works in Java

Ans.

Frameworks in Java provide pre-written code to help developers build applications more efficiently.

  • Frameworks like Spring, Hibernate, and Struts provide structure and functionality to Java applications.

  • Frameworks help developers follow best practices...read more

2w ago

Q. Tell me about Spring annotations.

Ans.

Spring annotations are used to provide metadata to Spring framework classes and components.

  • Annotations are used to configure Spring beans, dependency injection, AOP, and more

  • Examples include @Component, @Autowired, @RequestMapping, @Service, @Reposit...read more

Asked in TCS

2w ago

Q. Features of SringBoot

Ans.

Spring Boot is a framework that simplifies the development of Java applications by providing pre-configured settings and tools.

  • Spring Boot eliminates the need for manual configuration by providing defaults for most settings.

  • It includes embedded serve...read more

Asked in Capgemini

6d ago

Q. What are the differences between @RequestParam and @PathVariable, and what is the syntax for each?

Ans.

Requestparam vs pathvariable and syntax

  • RequestParam is used to extract query parameters from the URL, while PathVariable is used to extract values from the URI template

  • RequestParam syntax: @RequestParam("paramName") String paramValue

  • PathVariable synt...read more

Asked in Diverse Lynx

1w ago

Q. What databases are used by the Java front-end developer?

Ans.

The database used by Java front end developers varies depending on the project requirements.

  • Common databases used by Java front end developers include MySQL, PostgreSQL, Oracle, and MongoDB.

  • The choice of database depends on factors such as scalabilit...read more

Asked in Deloitte

2w ago

Q. How can you send values without using the sendKeys method?

Ans.

Values can be sent without using sendkeys method by directly manipulating the DOM or using JavaScriptExecutor.

  • Use JavaScriptExecutor to execute JavaScript code to set values of input fields.

  • Find the element using appropriate locators and then use Jav...read more

1w ago

Q. What are Spring beans?

Ans.

Spring beans are objects managed by the Spring IoC container, providing configuration and lifecycle management.

  • Spring beans are instantiated, configured, and managed by the Spring IoC container.

  • They can be defined in XML, Java annotations, or Java co...read more

Asked in Infosys

6d ago

Q. What is a bean factory?

Ans.

Bean factory is a container for managing beans in Spring framework.

  • Bean factory is responsible for creating, managing, and configuring beans in a Spring application.

  • It uses inversion of control (IoC) to manage the beans.

  • Beans are defined in a configu...read more

Asked in Molex

3d ago

Q. What is the get method?

Ans.

The get method is a function used to retrieve the value of a specified property from an object.

  • Used in JavaScript to access the value of a property in an object

  • Syntax: objectName.propertyName

  • Example: var person = {name: 'John', age: 30}; console.log(...read more

Asked in Fintuple

2w ago

Q. Important Spring boot Annotations

Ans.

Some important Spring Boot annotations include @SpringBootApplication, @RestController, @Autowired, @RequestMapping, @ComponentScan.

  • @SpringBootApplication - Used to mark the main class of a Spring Boot application.

  • @RestController - Used to define RES...read more

1w ago

Q. Explain all the features of Java 8.

Ans.

Java 8 introduced several new features including lambda expressions, streams, functional interfaces, and more.

  • Lambda expressions: Allow you to pass functionality as an argument to a method.

  • Streams: Provide a way to work with sequences of elements.

  • Fun...read more

Asked in Walmart

1w ago

Q. What is the difference between @Mock and @InjectMock?

Ans.

Difference between @Mock and @InjectMock annotations in Java testing

  • Use @Mock to create a mock object of a class or interface

  • Use @InjectMock to inject the mock object into the class being tested

  • Example: @Mock UserService userService; @InjectMock User...read more

Asked in MUFG

2w ago

Q. Regarding functional interfaces, what are the real-time use cases for static and default methods?

Ans.

Static and default methods in functional interfaces provide utility methods and default implementations for interface methods in real-time applications.

  • Static methods in functional interfaces can be used for utility methods that are not tied to a spe...read more

Previous
1
2
3
4
5
6
7
Next

Interview Experiences of Popular Companies

TCS Logo
3.6
 • 11.1k Interviews
Accenture Logo
3.7
 • 8.7k 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
Tech Mahindra Logo
3.5
 • 4.1k Interviews
HCLTech Logo
3.5
 • 4.1k Interviews
LTIMindtree Logo
3.7
 • 3k Interviews
IBM Logo
4.0
 • 2.5k Interviews
View all
Interview Tips & Stories
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories
Java 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 Lakh+

Reviews

10L+

Interviews

4 Crore+

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