Top 250 Java Interview Questions and Answers
Updated 26 Feb 2025
Q101. Java vs other language
Java is a popular language with strong community support and cross-platform compatibility.
Java is object-oriented and has automatic memory management
Other languages like C++ require manual memory management
Java has a large standard library and is used for web development, mobile apps, and enterprise software
Other languages like Python are popular for data science and machine learning
Java is compiled to bytecode and runs on a virtual machine, making it cross-platform compatibl...read more
Q102. Drawback of java api stream
One drawback of Java API Stream is that it can be less efficient for small collections.
Stream operations can be slower for small collections compared to traditional loops.
Stream operations can be harder to debug and understand for some developers.
Stream operations can lead to increased memory usage due to intermediate objects created during processing.
Q103. Different technologies available in java
Some technologies available in Java include Java EE, Spring Framework, Hibernate, Apache Struts, and JavaFX.
Java EE (Enterprise Edition) for building enterprise applications
Spring Framework for dependency injection and aspect-oriented programming
Hibernate for object-relational mapping
Apache Struts for developing web applications
JavaFX for creating rich internet applications
Q104. public static void getsum(int a,int b){System.out.println("a b method");}public static void getsum(int a,int b,int c){System.out.println("a b c method");}public static void getsum(int a,int ...b){System.out.pri...
read moreThe question is about method overloading in Java.
Method overloading allows multiple methods with the same name but different parameters.
The method to be called is determined at compile-time based on the arguments passed.
In the given code, there are three overloaded methods with the same name 'getsum'.
The first method takes two integers as arguments.
The second method takes three integers as arguments.
The third method takes one integer followed by a variable number of integers ...read more
Q105. Hopq to deploy java aps
Java applications can be deployed using various methods such as manual deployment, using build tools like Maven or Gradle, or using containerization platforms like Docker.
Use build tools like Maven or Gradle to package the application into a JAR or WAR file
Deploy the packaged application to a server or cloud platform
Utilize containerization platforms like Docker to create a container image of the application and deploy it
Automate deployment process using CI/CD tools like Jenk...read more
Q106. What happens in the backend when we cret an object in Java? What should be done before creating the method body in Java?
When an object is created in Java, memory is allocated in the heap for the object and its instance variables.
Memory is allocated in the heap for the object and its instance variables
Constructor is called to initialize the object
Reference to the object is returned
Q107. Why do you use public static void main in java why can't you use private/final
public static void main is used in Java as the entry point for the program. private/final cannot be used as they restrict access or prevent overriding.
public static void main is the standard entry point method in Java programs
Using private/final would restrict access or prevent overriding, which is not suitable for the entry point method
Example: public static void main(String[] args) { }
Q108. JPA vs Hibernate
JPA is a specification while Hibernate is an implementation of JPA.
JPA is a Java specification for managing relational data in applications.
Hibernate is an ORM framework that implements the JPA specification.
Hibernate provides additional features beyond JPA, such as caching and lazy loading.
JPA is vendor-neutral, allowing developers to switch between different JPA implementations.
Hibernate is a popular choice for JPA implementation due to its extensive features and community ...read more
Java Jobs
Q109. 1. Fundamental concepts in java
Fundamental concepts in Java include object-oriented programming, platform independence, and automatic memory management.
Object-oriented programming: Java is an object-oriented language, which means it uses objects to represent data and behavior.
Platform independence: Java code can run on any platform that has a Java Virtual Machine (JVM) installed.
Automatic memory management: Java has a garbage collector that automatically frees up memory that is no longer being used.
Other c...read more
Q110. 1 Write a procedure using user defined exception 2 write a procedure to get error, if updating end of the month. Etc....
Creating procedures with user defined exceptions and handling errors when updating at end of month.
Create a procedure with a user defined exception using 'RAISE_APPLICATION_ERROR' and 'EXCEPTION' keywords.
Use 'TO_CHAR(SYSDATE, 'DD')' to check if it is the end of the month before updating.
Handle the error by raising an exception if the update is attempted at the end of the month.
Example: CREATE OR REPLACE PROCEDURE update_data AS BEGIN IF TO_CHAR(SYSDATE, 'DD') = '31' THEN RAI...read more
Q111. All Java 8 new features
Java 8 introduced several new features including 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 with lambda expressions.
Streams provide a way to work with sequences of elements efficiently.
Default methods allow interfaces to have method implementations.
Some other features include the new Date and Time API, N...read more
Q112. 2) experience with vue.js and java?
I have experience with Vue.js and Java, including building web applications and implementing front-end and back-end functionalities.
Developed a web application using Vue.js for the front-end and Java for the back-end
Implemented RESTful APIs in Java to communicate with the Vue.js front-end
Utilized Vue.js components to create dynamic and interactive user interfaces
Q113. AWT Token working
AWT Token is a security token used for authentication and authorization in Java applications.
AWT stands for Abstract Window Toolkit
AWT Token is used for managing user authentication and authorization in Java applications
It provides a secure way to control access to resources based on user credentials
Q114. Spring JPA vs Hibernate
Spring JPA is a part of the Spring Data project that makes it easier to work with JPA. Hibernate is a popular ORM framework.
Spring JPA is a higher level abstraction on top of JPA, providing more features and simplifying development.
Hibernate is a powerful ORM framework that provides mapping between Java objects and database tables.
Spring JPA can be used with Hibernate as the underlying ORM provider.
Hibernate offers more flexibility and control over the database interactions c...read more
Q115. Implementation of database connection pool in java
Database connection pool in Java helps manage multiple database connections efficiently.
Use a connection pool library like HikariCP or Apache DBCP.
Set up the pool with a maximum number of connections, timeout settings, etc.
Acquire and release connections from the pool as needed in your Java code.
Q116. Java 8 streams - how they function internally
Java 8 streams are functional programming constructs that allow for efficient processing of large data sets.
Streams are composed of a source, intermediate operations, and a terminal operation.
Intermediate operations include filter, map, and sorted, and are lazily evaluated.
Terminal operations trigger the evaluation of the stream and include forEach, reduce, and collect.
Streams can be parallelized for even greater performance.
Streams are designed to work with lambdas and funct...read more
Q117. Concurrent package: internal working of CopyOnWriteArrayList Diff between synchronized collection and concurrent collection
Explaining CopyOnWriteArrayList and difference between synchronized and concurrent collections.
CopyOnWriteArrayList is a thread-safe variant of ArrayList where all mutative operations are implemented by making a new copy of the underlying array.
Synchronized collections use a single lock to synchronize access to the collection, while concurrent collections use multiple locks to allow concurrent access.
Concurrent collections are designed to handle high-concurrency scenarios, wh...read more
Q118. Classloaders in java
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 delegation model, where they first delegate to their parent classloader before attempting to load the class themselves.
Classloaders can be used for dynamic class loading and hot-swapping of code at runtime.
Q119. latest feature of java 8
Java 8 introduced lambda expressions and functional interfaces.
Lambda expressions allow for more concise and readable code.
Functional interfaces enable the use of lambda expressions.
Stream API for processing collections of data.
Date and Time API for improved handling of date and time.
Default methods in interfaces for backward compatibility.
Q120. Stream and collection api usage
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 objects.
Stream API can be used to filter, map, reduce, and collect data from collections.
Collection API includes interfaces like List, Set, and Map for different data structures.
Q121. Objects in java 8
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 functional style.
Functional interfaces like Predicate, Function, and Consumer are commonly used with lambda expressions.
Q122. java 8 improvements
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 expressions.
Streams provide a way to work with sequences of elements efficiently.
Default methods allow interfaces to have concrete methods.
Optional class helps to handle null values more effectively.
Q123. What is build in Java ?
Build in Java refers to the process of compiling source code into executable code.
Build process involves compiling, testing, and packaging the code
Java build tools like Maven and Gradle automate the build process
Build artifacts can be JAR, WAR, or EAR files
Build process can be customized using build scripts like Ant
Q124. Differnence between C and Java
C is a procedural programming language while Java is an object-oriented programming language.
C is a low-level language while Java is a high-level language.
C requires manual memory management while Java has automatic memory management.
C supports pointers while Java does not.
C is platform-dependent while Java is platform-independent.
C has a simpler syntax compared to Java.
Q125. Differnece between C++ and Java
C++ is a compiled language with pointers and memory management, while Java is an interpreted language with garbage collection.
C++ is faster than Java due to direct memory access and lack of garbage collection
Java is more secure than C++ due to its sandbox environment
C++ allows for low-level system programming, while Java is better suited for web applications
C++ has multiple inheritance, while Java only has single inheritance
C++ has operator overloading, while Java does not
Q126. what are spring bean scope ?
Spring bean scope defines the lifecycle and visibility of a bean in the Spring container.
Singleton scope: Only one instance of the bean is created and shared across the application.
Prototype scope: A new instance of the bean is created every time it is requested.
Request scope: A new instance of the bean is created for each HTTP request.
Session scope: A new instance of the bean is created for each HTTP session.
Global session scope: Similar to session scope, but for global HTTP...read more
Q127. Why python is popular in market and java popularity is decreasing?
Python's simplicity, versatility, and ease of use make it popular. Java's complexity and verbosity make it less popular.
Python has a simpler syntax and is easier to learn than Java.
Python is versatile and can be used for a wide range of applications, including web development, data analysis, and artificial intelligence.
Java's verbosity and complexity make it less appealing to developers.
Python has a large and active community that contributes to its popularity.
Java's populari...read more
Q128. Explain about Java 8 features
Java 8 introduced several new features including lambda expressions, functional interfaces, and streams.
Lambda expressions allow for functional programming and simplify code
Functional interfaces enable the use of lambda expressions
Streams provide a way to process collections of data in a functional style
Default methods allow for adding methods to interfaces without breaking existing implementations
Date and time API improvements
Nashorn JavaScript engine
Q129. What @SpringBootApplication will do
@SpringBootApplication is a Spring Boot annotation that enables auto-configuration and component scanning.
Enables auto-configuration of the Spring application context
Enables component scanning for beans
Provides a convenient shortcut for @Configuration, @EnableAutoConfiguration, and @ComponentScan annotations
Can be used as a single entry point for the Spring Boot application
Q130. What is java, html
Java is a programming language used for developing applications, while HTML is a markup language used for creating web pages.
Java is an object-oriented programming language known for its portability and versatility.
HTML is a markup language used to create the structure of web pages.
Java is used for developing applications like mobile apps, web applications, and enterprise software.
HTML is used to define the structure of web pages, including headings, paragraphs, links, and im...read more
Q131. Explain Life cycle methods
Life cycle methods are functions that are called at different stages of a component's life cycle.
There are three categories of life cycle methods: mounting, updating, and unmounting.
Mounting methods are called when a component is first created and added to the DOM.
Updating methods are called when a component's state or props change.
Unmounting methods are called when a component is removed from the DOM.
Examples of life cycle methods include componentDidMount, componentDidUpdat...read more
Q132. What are the features in java 8
Java 8 introduced several new features including lambda expressions, streams, and default methods.
Lambda expressions for functional programming
Streams for efficient processing of large data sets
Default methods to add new functionality to interfaces
Date and Time API for improved handling of date and time
Nashorn JavaScript engine for improved performance
Parallel array sorting for faster sorting of large arrays
Q133. No Java is not 100 % Object Oriented, its datatypes are not objects
Java is not 100% Object Oriented because its primitive data types are not objects.
Java has primitive data types like int, double, boolean which are not objects and do not inherit from a common class.
However, Java provides wrapper classes like Integer, Double, Boolean to treat primitives as objects.
Java also supports features like inheritance, encapsulation, and polymorphism which are key aspects of Object Oriented Programming.
Q134. What is the keyword used in interface if we want concreate method?
The keyword used in interface for concrete method is 'default'.
The 'default' keyword is used in interfaces to provide a default implementation for a method.
It allows interfaces to have concrete methods without requiring implementing classes to override them.
Example: 'default void methodName() { // method implementation }'
Q135. What is the different technique to inject bean in application context
Different techniques for injecting beans in application context
Constructor Injection
Setter Injection
Field Injection
Method Injection
Q136. Different between java and .net
Java is a programming language while .NET is a framework that supports multiple programming languages.
Java is platform-independent, while .NET is primarily used on Windows.
Java uses a virtual machine for execution, while .NET uses a Common Language Runtime (CLR).
Java has a larger community and more open-source libraries, while .NET has better integration with Microsoft products.
Java is mainly used for web applications, while .NET is commonly used for enterprise applications.
E...read more
Q137. Name some methods in Executor framework?
Some methods in Executor framework include execute(), submit(), shutdown(), awaitTermination(), and invokeAll().
execute() - Used to execute the given command at some time in the future.
submit() - Submits a Runnable or Callable task for execution and returns a Future representing the task.
shutdown() - Initiates an orderly shutdown in which previously submitted tasks are executed, but no new tasks will be accepted.
awaitTermination() - Blocks until all tasks have completed execu...read more
Q138. difference between streams and parallel streams
Streams process elements sequentially, while parallel streams process elements concurrently.
Streams process elements one by one in a sequential manner.
Parallel streams process elements concurrently, potentially utilizing multiple threads for faster processing.
Streams are suitable for smaller datasets or when order matters.
Parallel streams are more efficient for larger datasets or when order is not important.
Example: Stream processing a list of numbers vs. parallel stream proc...read more
Q139. What is Java and explain the execution process
Java is a high-level programming language used for developing applications and software.
Java is an object-oriented language
It is platform-independent
Java code is compiled into bytecode
The bytecode is executed by the Java Virtual Machine (JVM)
JVM converts bytecode into machine code
Java programs are executed in a sandbox environment for security
Java has automatic memory management
Q140. What is the use of Intent & Intent Filters?
Intent is used to communicate between components of an app or between different apps. Intent Filters are used to specify the type of intent a component can handle.
Intent is used to start an activity, service or broadcast receiver.
Intent can also be used to pass data between components.
Intent Filters are used to specify the type of intent a component can handle.
Intent Filters are declared in the AndroidManifest.xml file.
Intent Filters can be used to launch an activity from ano...read more
Q141. Are u good at java or sql?
I am proficient in both Java and SQL.
I have experience in developing Java applications using various frameworks like Spring, Hibernate, and Struts.
I am skilled in writing complex SQL queries and optimizing database performance.
I have worked on projects that involve integrating Java and SQL technologies.
I am constantly learning and keeping up with the latest updates in both Java and SQL.
Q142. What to choose nodejs or java.
It depends on the specific project requirements and team expertise.
Consider the project requirements - Node.js is great for real-time applications, while Java is better for large-scale enterprise applications.
Evaluate team expertise - If your team is more familiar with JavaScript, Node.js may be the better choice.
Performance - Java is generally faster and more efficient than Node.js.
Scalability - Java is known for its scalability, making it a good choice for growing applicati...read more
Q143. What is java and pattern question?
Java is a popular programming language used for developing software applications. Design patterns are reusable solutions to common problems in software design.
Java is an object-oriented programming language known for its platform independence and versatility.
Design patterns are best practices for solving common software design problems.
Examples of design patterns include Singleton, Factory, Observer, and Strategy patterns.
Q144. What is java and method
Java is a popular programming language used for developing applications, while a method is a block of code that performs a specific task.
Java is an object-oriented programming language known for its portability and versatility.
Methods in Java are used to define behavior for objects and can be called to perform specific tasks.
Example: public void printMessage() { System.out.println("Hello, World!"); }
Q145. what is java & datatypes
Java is a popular programming language used for developing applications. Data types in Java define the type of data that a variable can hold.
Java is an object-oriented programming language.
Data types in Java include int, double, boolean, and String.
Each data type has a specific range of values it can hold.
Variables in Java must be declared with a specific data type before use.
Q146. Difference between intermediate and terminal operations in stream
Intermediate operations return a stream and do not produce a result, while terminal operations produce a result.
Intermediate operations are lazy and do not execute until a terminal operation is called
Examples of intermediate operations include filter(), map(), and sorted()
Examples of terminal operations include forEach(), reduce(), and collect()
Terminal operations are eager and execute immediately
Q147. How is kotlin better than java?
Kotlin is better than Java due to its concise syntax, null safety, extension functions, and interoperability with Java.
Kotlin has a more concise syntax compared to Java, reducing boilerplate code.
Kotlin has built-in null safety features, reducing the risk of null pointer exceptions.
Kotlin supports extension functions, allowing developers to add new functionality to existing classes.
Kotlin is fully interoperable with Java, making it easy to use both languages in the same proje...read more
Q148. Tell me about what is completable future
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 operations.
It provides methods like thenApply, thenCompose, thenCombine, etc. for combining results.
Example: CompletableFuture
future = CompletableFuture.supplyAsync(() -> 10);
Q149. How to write name program in eclipse
To write a name program in Eclipse, create a new Java project and class, then write the code to print the name.
Create a new Java project in Eclipse
Create a new class in the project
Write the code to print the name using System.out.println()
Run the program to see the output
Q150. What is @ peek annotation, @qualifier annotation
The @Peek annotation is used in Java to mark a method as a peek operation in a stream. The @Qualifier annotation is used in Spring to specify which bean should be autowired when multiple beans of the same type are present.
The @Peek annotation is used in Java streams to perform a side-effect operation on each element without changing the elements themselves.
The @Qualifier annotation in Spring is used to disambiguate beans of the same type by specifying the bean name to be inje...read more
Q151. give the brief of spring annotations
Spring annotations are used to provide metadata to Spring framework classes and methods.
Annotations like @Component, @Controller, @Service, and @Repository are used for component scanning and auto-wiring.
@Autowired is used for dependency injection.
@RequestMapping is used to map web requests to specific handler methods.
@Transactional is used for managing transactions.
Annotations like @Value, @Qualifier, and @Scope are used for configuring beans.
Q152. tell us bout the college project in java
Developed a college project in Java to create a student management system.
Used Java programming language to develop the project
Implemented features such as student registration, course enrollment, and grade tracking
Utilized object-oriented programming concepts like classes and inheritance
Integrated a graphical user interface for user interaction
Q153. Types of wait, handle & handles, findElement & findElements
Wait types include implicit, explicit, and fluent. Handles refer to browser windows or tabs. findElement(s) locate web elements.
Implicit wait waits for a certain amount of time before throwing an exception if the element is not found
Explicit wait waits for a certain condition to be met before proceeding
Fluent wait waits for a certain condition to be met and polls at regular intervals
Handles are used to switch between browser windows or tabs
findElement locates the first web el...read more
Q154. Frameworks in Java?
Frameworks in Java
Java Spring Framework
Java Hibernate Framework
Java Struts Framework
Java Play Framework
Java JSF (JavaServer Faces) Framework
Q155. tell me about the basics of java and react
Java is a popular programming language known for its platform independence, while React is a JavaScript library for building user interfaces.
Java is an object-oriented programming language used for developing various types of applications.
React is a JavaScript library developed by Facebook for building interactive user interfaces.
Java programs are compiled into bytecode that can run on any Java Virtual Machine (JVM).
React allows developers to create reusable UI components tha...read more
Q156. Can we keep the reference variable of a parent class in the object of a child class?
Yes, we can keep the reference variable of a parent class in the object of a child class.
This is possible because a child class is a type of parent class and can inherit its properties and methods.
This allows for polymorphism, where a parent class reference variable can refer to an object of a child class.
For example, if we have a parent class Animal and a child class Dog, we can create an object of Dog and assign it to an Animal reference variable.
Q157. What is Meta space in Java 8 ?
Meta space is a memory space in Java 8 used to store class metadata.
Meta space replaces the permanent generation (PermGen) space in Java 8.
It stores class metadata such as class name, access modifiers, and constant pool.
Meta space is dynamically sized and can expand or shrink based on the application's needs.
It can be configured using the -XX:MetaspaceSize and -XX:MaxMetaspaceSize JVM options.
Q158. What is Java concurrency?
Java concurrency refers to the ability of multiple threads to execute simultaneously in a Java program.
Java concurrency allows for efficient utilization of resources by running multiple tasks concurrently.
It involves concepts like threads, synchronization, locks, and atomic variables.
Examples include using the 'synchronized' keyword to protect critical sections of code from concurrent access.
Q159. Why do we have @functionalInterface if we can make any interface as 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
Q160. Explaing colletion framework
Collection framework is a set of classes and interfaces that provide a way to store and manipulate groups of objects.
It provides interfaces like List, Set, Map, Queue, etc.
It allows easy manipulation of data structures like arrays, linked lists, trees, etc.
It provides algorithms like sorting, searching, etc.
It is a part of Java API and is widely used in Java programming.
Example: ArrayList is a class that implements the List interface and provides dynamic array functionality.
Q161. Difference between getwindowhandle and getwindowhandles
getwindowhandle returns the handle of the current window, while getwindowhandles returns the handles of all open windows.
getwindowhandle returns a single window handle, while getwindowhandles returns multiple window handles
getwindowhandle is used to switch focus to a specific window, while getwindowhandles is used to handle multiple windows simultaneously
Example: driver.getwindowhandle() vs driver.getwindowhandles()
Q162. What is the purpose of using default methods in java8?
Default methods in Java 8 allow interfaces to have method implementations, enabling backward compatibility and reducing code duplication.
Default methods were introduced in Java 8 to provide a way to add new methods to interfaces without breaking existing implementations.
They allow interfaces to have method implementations, which was not possible before Java 8.
Default methods can be overridden in implementing classes to provide specific implementations.
They help in reducing co...read more
Q163. What is your Prefer Coding language What is the java What is the piiler of the java
Java is a popular object-oriented programming language used for developing various applications.
Java is platform-independent and can run on any operating system
It is used for developing web, mobile, and desktop applications
Java is known for its security features and is widely used in enterprise applications
The Java compiler is the piiler of the Java programming language
Q164. What are functional Interfaces?
Functional interfaces are interfaces with only one abstract method, used for functional programming in Java.
Functional interfaces can have multiple default or static methods, but only one abstract method.
They are used in lambda expressions and method references for functional programming.
Examples include java.lang.Runnable, java.util.Comparator, and java.util.function.Function.
Q165. What is parallel stream
Parallel stream is a feature in Java that allows processing elements of a stream concurrently.
Parallel stream can be created from a regular stream using parallel() method.
It utilizes multiple threads to process elements in parallel, improving performance for large datasets.
However, parallel stream may not always be faster than sequential stream due to overhead of managing multiple threads.
Example: List
list = Arrays.asList("apple", "banana", "cherry"); list.parallelStream().f...read more
Q166. Difference between @requestbody and @responsebody
Difference between @requestbody and @responsebody annotations in Spring MVC
The @RequestBody annotation is used to bind the HTTP request body to a method parameter in Spring MVC controller
The @ResponseBody annotation is used to bind the return value of a method to the HTTP response body in Spring MVC
Example: @RequestBody User user - binds the request body to a User object parameter
Example: @ResponseBody String hello() - binds the return value of hello() method to the response ...read more
Q167. The latest technology of java or angular.
Both Java and Angular have recently released new versions with significant updates and improvements.
Java 16 was released in March 2021 with new features like Records, Pattern Matching, and Vector API.
Angular 12 was released in May 2021 with improvements in performance, accessibility, and developer experience.
Java and Angular are both widely used technologies in the software development industry.
It's important for technical recruiters to stay up-to-date with the latest technol...read more
Q168. various Springboot Annotations.
Springboot annotations are used to simplify the development process and provide additional functionality.
Annotations like @RestController and @RequestMapping are used to create RESTful web services.
@Autowired is used for dependency injection.
@Transactional is used to manage transactions.
@Component is used to mark a class as a Spring component.
@Value is used to inject values from properties files or environment variables.
@Scheduled is used to schedule tasks to run at specific ...read more
Q169. Frame works in Java
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 and reduce the amount of code they need to write.
Frameworks often include features like dependency injection, ORM mapping, and MVC architecture.
Using frameworks can speed up development time and make applications more maintainabl...read more
Q170. Requestparam vs pathvariable and syntax of both
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 syntax: @PathVariable("varName") String varValue
Example: @RequestParam("id") String id
Example: @PathVariable("name") String name
Q171. Java program on data structures
Java program on data structures
Use Java to implement common data structures like arrays, linked lists, stacks, queues, trees, and graphs
Practice implementing algorithms like sorting, searching, and traversal on these data structures
Understand the time and space complexity of different operations on data structures
Q172. Java 8 in depth
Java 8 introduced several new features including lambda expressions, streams, and functional interfaces.
Lambda expressions allow for more concise code by enabling functional programming.
Streams provide a way to process collections of objects in a functional style.
Functional interfaces are interfaces with a single abstract method, which can be implemented using lambda expressions.
Java 8 also introduced the Optional class to handle null values more effectively.
Q173. Design principles in Java.
Design principles in Java focus on creating modular, reusable, and maintainable code.
Single Responsibility Principle - Each class should have only one responsibility.
Open/Closed Principle - Classes should be open for extension but closed for modification.
Liskov Substitution Principle - Subtypes should be substitutable for their base types.
Interface Segregation Principle - Clients should not be forced to depend on interfaces they do not use.
Dependency Inversion Principle - Hig...read more
Q174. Spring is immutable or mutable
Spring is immutable
Spring framework is immutable
Once a Spring bean is created, its state cannot be changed
Any modifications to a Spring bean result in a new instance being created
Q175. what is try with resources
Try with resources is a feature introduced in Java 7 to automatically close resources after use.
It simplifies the code by eliminating the need for a finally block to close the resource
The resource must implement the AutoCloseable interface
Multiple resources can be declared in a single try-with-resources statement
Example: try(FileInputStream fis = new FileInputStream("file.txt")) { //code }
Q176. Diff between C and Java?
C is a procedural language while Java is an object-oriented language.
C is compiled while Java is interpreted
C has pointers while Java does not
Java has automatic garbage collection while C does not
Java has platform independence while C does not
Java has built-in exception handling while C does not
Q177. can youdo coding in c++ or java?
Yes, I can do coding in both C++ and Java.
I have experience in writing code in C++ and Java.
I am familiar with the syntax and features of both languages.
I have worked on projects using C++ and Java.
I can provide examples of my coding work in both languages if needed.
Q178. Whats the difference between @Service and @Component annotations?
The @Service annotation is a specialization of the @Component annotation and is used to indicate that a class is a service.
Both @Service and @Component annotations are used to indicate that a class is a Spring-managed component.
@Service is a specialization of @Component and is used to indicate that a class is a service layer component.
The @Service annotation is used to add a layer of abstraction between the controller and the DAO layer.
The @Service annotation is used to provi...read more
Q179. Why not python instead of using Java?
Java is preferred for its performance, scalability, and strong typing compared to Python.
Java is statically typed, which helps catch errors at compile time, while Python is dynamically typed.
Java is faster in terms of execution speed compared to Python.
Java is preferred for large-scale enterprise applications due to its scalability and performance.
Java has a strong ecosystem and support for multi-threading, making it suitable for high-performance applications.
Q180. Tell about Java 8 features
Java 8 introduced several new features including lambda expressions, streams, and default methods.
Lambda expressions allow for functional programming and simplify code.
Streams provide a way to process collections of data in a functional way.
Default methods allow for adding new methods to interfaces without breaking existing implementations.
Other features include the Date and Time API, Nashorn JavaScript engine, and improved security.
Java 8 also introduced the concept of Optio...read more
Q181. name few annotations in springboot
Some annotations in Spring Boot are @RestController, @Autowired, @Component, @RequestMapping, @Service.
@RestController - used to define RESTful web services.
@Autowired - used for automatic dependency injection.
@Component - marks a java class as a bean so that the component-scanning mechanism of Spring can pick it up and pull it into the application context.
@RequestMapping - used to map web requests to specific handler classes or methods.
@Service - used to indicate that a clas...read more
Q182. Difference between Java and Java. script
Java is a programming language while JavaScript is a scripting language used for web development.
Java is a compiled language while JavaScript is an interpreted language.
Java is used for developing standalone applications, web applications, and Android apps while JavaScript is used for web development.
Java is statically typed while JavaScript is dynamically typed.
Java code is executed on the server-side while JavaScript code is executed on the client-side.
Java is more complex ...read more
Q183. Explain the Java new features in 1.8 version
Java 1.8 introduced lambda expressions, default methods, and functional interfaces.
Lambda expressions allow functional programming in Java.
Default methods allow adding new methods to interfaces without breaking existing implementations.
Functional interfaces are interfaces with a single abstract method, used for lambda expressions.
Stream API for processing collections and arrays.
Date and Time API for easier handling of date and time.
Nashorn JavaScript engine for running JavaSc...read more
Q184. What is java opps
Java OOPs (Object-Oriented Programming) is a programming paradigm based on the concept of objects, which can contain data in the form of fields and code in the form of procedures.
Java OOPs focuses on creating objects that interact with each other to solve a problem.
Key principles of Java OOPs include Inheritance, Encapsulation, Polymorphism, and Abstraction.
Example: Inheritance allows a class to inherit properties and behavior from another class, promoting code reusability.
Q185. How to call default method of interface if class implemented multiple interfaces.
To call a default method of an interface when a class implements multiple interfaces, use the interface name followed by the method name.
Use InterfaceName.super.methodName() to call the default method of a specific interface.
If a class implements multiple interfaces with default methods of the same name, you must specify the interface name to call the desired method.
Example: Interface1.super.defaultMethod() to call the defaultMethod() of Interface1.
Q186. What are the basic role of JAVA in the development of software?
JAVA is a versatile programming language used for developing various software applications.
JAVA is platform-independent and can run on any operating system
It is object-oriented and supports multithreading
JAVA is widely used for developing web applications, mobile applications, and enterprise software
It provides a vast library of pre-built classes and APIs for developers to use
JAVA is also used for developing games, scientific applications, and financial applications
Q187. what is java and .net
Java and .NET are both popular programming languages used for developing software applications.
Java is a high-level programming language developed by Sun Microsystems, now owned by Oracle. It is platform-independent and object-oriented.
.NET is a framework developed by Microsoft for building Windows applications. It supports multiple programming languages like C#, VB.NET, and F#.
Java applications run on a Java Virtual Machine (JVM), while .NET applications run on the Common La...read more
Q188. multithreading in spring boot
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 executed in a separate thread.
ThreadPoolTaskExecutor can be configured to control the number of threads used for executing async methods.
Example: @Async public void asyncMethod() { // method logic }
Q189. Difference between findFirst and findAny
findFirst returns the first element in a stream, while findAny returns any element in a stream.
findFirst is deterministic and will always return the first element in a stream, while findAny is non-deterministic and can return any element.
findAny is useful for parallel processing as it can return any available element without the need to search for the first one.
findFirst is typically used when the order of elements matters, while findAny is used when any element can satisfy t...read more
Q190. What is service, fragment,
A service is a component that performs operations in the background without a user interface. A fragment is a modular section of an activity that has its own lifecycle and UI.
Service is used for long-running operations such as network calls or playing music in the background.
Fragments are reusable UI components that can be added or removed from an activity dynamically.
Services and fragments are both important components in Android development.
Q191. Your score is good sql than java?
I have a good understanding of both SQL and Java.
I have experience working with both SQL and Java in various projects.
I have a strong understanding of SQL syntax and can write complex queries.
I am proficient in Java and have worked with various frameworks and libraries.
I believe that having a good understanding of both SQL and Java is important for a Java Developer.
Q192. Why we use java rather then Node.js?
Java is preferred for its strong typing, scalability, platform independence, and extensive libraries.
Java is statically typed, which helps catch errors at compile time.
Java is known for its scalability, making it suitable for large enterprise applications.
Java is platform independent, allowing it to run on any device with a Java Virtual Machine (JVM).
Java has a vast array of libraries and frameworks available for various functionalities.
Node.js, on the other hand, is single-t...read more
Q193. What is java design latterns
Java design patterns are reusable solutions to common problems encountered in software design.
Java design patterns help in creating flexible, reusable, and maintainable code.
Examples of Java design patterns include Singleton, Factory, Observer, and Strategy.
Design patterns can be categorized into three groups: creational, structural, and behavioral.
Q194. Explain java datatypes in java
Java datatypes are used to define the type of data that a variable can hold.
Java has two categories of datatypes: primitive and non-primitive
Primitive datatypes include int, double, char, boolean, etc.
Non-primitive datatypes include classes, interfaces, arrays, etc.
Each datatype has a specific size and range of values it can hold
Q195. Characters finding using Stream Api
Using Stream API to find characters in a string
Use the chars() method to convert the string to an IntStream of characters
Use filter() method to filter out specific characters
Use collect() method to collect the characters into an array of strings
Q196. How Kotlin is better than Java.
Kotlin is better than Java due to its concise syntax, null safety, interoperability, and improved performance.
Kotlin has concise syntax which reduces boilerplate code and makes code more readable.
Kotlin provides null safety features to prevent NullPointerExceptions at runtime.
Kotlin is fully interoperable with Java, allowing developers to use both languages in the same project.
Kotlin offers improved performance compared to Java in terms of compilation speed and runtime perfor...read more
Q197. Difference between @bean and @ component
The @Bean annotation is used to define a method that returns an object to be registered as a bean in the Spring application context. The @Component annotation is used to indicate that a class is a Spring component.
The @Bean annotation is used on methods within a @Configuration class to define Spring beans.
The @Component annotation is used on classes to indicate that they are Spring components.
The @Bean annotation allows for more flexibility in defining bean creation logic com...read more
Q198. Tell me spring boot Annotation?
Spring Boot annotations are used to simplify the development process by providing shortcuts for common tasks.
Annotations like @SpringBootApplication, @RestController, @Autowired, @GetMapping, @PostMapping are commonly used in Spring Boot applications.
These annotations help in configuring the application, defining REST endpoints, injecting dependencies, and mapping HTTP requests to controller methods.
For example, @SpringBootApplication is used to mark the main class of a Sprin...read more
Q199. Java project you worked previously
Developed a Java project for a banking application
Used Java to create backend logic for customer transactions
Implemented security features to protect sensitive data
Integrated with external APIs for currency exchange rates
Q200. Functional interface in Java 8 and it's purpose.
Functional interface is an interface with only one abstract method. It enables lambda expressions and method references.
Functional interface is used to enable lambda expressions and method references in Java 8.
It has only one abstract method and can have any number of default or static methods.
Examples of functional interfaces are Runnable, Consumer, Predicate, Function, etc.
Top Interview Questions for Related Skills
Interview Questions of Java Related Designations
Interview experiences of popular companies
Reviews
Interviews
Salaries
Users/Month