Top 250 Java Interview Questions and Answers 2025

Updated 23 Jan 2025

Q1. Can 'this' keyword be equal to null?

Ans.

No, the 'this' keyword cannot be equal to null.

  • The 'this' keyword refers to the current instance of a class.

  • It is used to access the members of the current object.

  • Since 'this' refers to an object, it cannot be null.

View 1 answer

Q2. What is c code in java

Ans.

C code in Java refers to the use of the Java Native Interface (JNI) to incorporate C code into Java programs.

  • C code in Java is typically used when performance optimization or low-level system access is required.

  • JNI allows Java programs to call C functions and use C libraries.

  • C code can be written separately and compiled into a shared library, which is then loaded and used by Java code.

  • JNI provides a way to pass data between Java and C, handle exceptions, and manage memory.

  • Exa...read more

View 1 answer
Frequently asked in

Q3. what are spring bean scope ?

Ans.

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

View 1 answer

Q4. Why python is differ from Java?

Ans.

Python is dynamically typed and has simpler syntax, while Java is statically typed and has more complex syntax.

  • Python is interpreted, while Java is compiled

  • Python has automatic memory management, while Java requires manual memory management

  • Python has a smaller standard library compared to Java

  • Python is often used for scripting and data analysis, while Java is used for enterprise applications and Android development

Add your answer
Are these interview questions helpful?

Q5. 9. What is @SpringBootApplication?

Ans.

A convenience annotation that combines @Configuration, @EnableAutoConfiguration, and @ComponentScan.

  • Used to bootstrap a Spring Boot application.

  • Automatically configures the Spring application based on the dependencies added to the classpath.

  • Scans the package and its sub-packages for components and services.

  • Example: @SpringBootApplication public class MyApplication { public static void main(String[] args) { SpringApplication.run(MyApplication.class, args); } }

Add your answer

Q6. Difference between Spring IOC and Dependency Injection

Ans.

Spring IOC is a container that manages the lifecycle of Java objects. Dependency Injection is a design pattern that allows objects to be loosely coupled.

  • Spring IOC is a container that manages the creation and destruction of objects

  • Dependency Injection is a design pattern that allows objects to be loosely coupled

  • Spring IOC uses Dependency Injection to inject dependencies into objects

  • Dependency Injection can be implemented without using Spring IOC

Add your answer
Frequently asked in
Share interview questions and help millions of jobseekers 🌟

Q7. tell me java8 features

Ans.

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

  • Lambda expressions allow you to write code in a more concise way by replacing anonymous classes.

  • Functional interfaces are interfaces with a single abstract method, which can be implemented using lambda expressions.

  • Streams provide a way to work with sequences of elements and perform operations like filter, map, reduce, etc.

  • Default methods allow interfaces to...read more

Add your answer

Q8. 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 web applications, mobile apps, and enterprise software.

  • C++ is compiled, while Java is both compiled and interpreted.

  • C++ allows for direct memory manipulation, while Java has automatic memory management.

  • C++ is known for its speed ...read more

Add your answer
Frequently asked in

Java Jobs

DevOps Engineer 4-9 years
Apple INC
4.3
Hyderabad / Secunderabad
Software Development Specialist III ( Java, Microservices ) 3-7 years
Verizon Data Services India Pvt.Ltd
4.1
Hyderabad / Secunderabad
Senior Engineer Consultant - Java, React JS 4-7 years
Verizon Data Services India Pvt.Ltd
4.1
Hyderabad / Secunderabad

Q9. Difference between runnable and callable interface?

Ans.

Runnable interface is used for running a task, while Callable interface is used for returning a result after running a task.

  • Runnable interface has a run() method that does not return any value.

  • Callable interface has a call() method that returns a value.

  • Callable interface can throw an exception while Runnable interface cannot.

  • Callable interface can be used with ExecutorService to submit tasks and get results.

  • Example of Runnable: Thread t = new Thread(new Runnable() { public vo...read more

Add your answer

Q10. Difference between @requestbody and @responsebody

Ans.

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

Add your answer

Q11. Difference between @Bean, @Component

Ans.

Both @Bean and @Component are used for creating beans in Spring framework.

  • The @Bean annotation is used to explicitly declare a single bean.

  • The @Component annotation is used to declare a class as a Spring component.

  • The @Bean method is used in a configuration class to create and configure a bean.

  • The @Component annotation is used on a class to indicate that it is a Spring-managed component.

  • The @Bean method can be used to create a bean of any class, not just the one in which it i...read more

Add your answer

Q12. What is java and explain its features

Ans.

Java is a high-level programming language known for its platform independence and object-oriented features.

  • Java is platform-independent, meaning it can run on any device with a Java Virtual Machine (JVM)

  • It is object-oriented, allowing for modular and reusable code

  • Java is known for its robust standard library, providing a wide range of pre-built functionality

  • It supports multithreading, allowing for concurrent execution of tasks

  • Java is statically typed, catching errors at compi...read more

Add your answer

Q13. what is the difference between stream and parallel stream

Ans.

Stream is sequential while parallel stream is concurrent

  • Stream is a sequence of elements that can be processed sequentially

  • Parallel stream is a sequence of elements that can be processed concurrently

  • Parallel stream can improve performance for large datasets

  • Parallel stream uses multiple threads to process elements in parallel

  • Stream is suitable for small datasets or when order of processing is important

Add your answer

Q14. What is completableFuture?

Ans.

completableFuture is a class in Java that represents a future result of an asynchronous computation.

  • It is used for asynchronous programming in Java.

  • It can be used to chain multiple asynchronous operations.

  • It supports callbacks and combinators.

  • It can handle exceptions and timeouts.

  • Example: CompletableFuture.supplyAsync(() -> "Hello").thenApply(s -> s + " World").thenAccept(System.out::println);

Add your answer

Q15. What is abstrack class?

Ans.

Abstract class is a class that cannot be instantiated and may contain abstract methods.

  • Cannot be instantiated directly

  • May contain abstract methods that must be implemented by subclasses

  • Used to define a common interface for subclasses

Add your answer
Frequently asked in

Q16. Find java elements in selenium

Ans.

Java elements in Selenium can be found using various methods like findElement, findElements, etc.

  • Use findElement method to locate a single element in the DOM

  • Use findElements method to locate multiple elements in the DOM

  • Locate elements by ID, class name, name, tag name, xpath, css selector, etc.

Add your answer
Frequently asked in

Q17. tell me about the basics of java and react

Ans.

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

Add your answer

Q18. What is java design latterns

Ans.

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.

Add your answer

Q19. What’s is the use of 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 programming concepts in Java.

  • Examples include java.lang.Runnable, java.util.Comparator, and java.util.function.Predicate.

Add your answer

Q20. Explain the collection framework

Ans.

Collection framework is a set of classes and interfaces that provide a way to store and manipulate groups of objects.

  • It includes interfaces like List, Set, and Map

  • It provides implementations like ArrayList, HashSet, and HashMap

  • It allows for easy manipulation of data structures and efficient searching and sorting

  • Example: List names = new ArrayList<>(); names.add("John"); names.add("Jane");

  • Example: Map ages = new HashMap<>(); ages.put("John", 30); ages.put("Jane", 25);

Add your answer

Q21. How do you monitor java app newrelic

Ans.

Monitoring Java applications with New Relic involves setting up agents and configuring alerts.

  • Install New Relic Java agent in the application server

  • Configure New Relic settings in the newrelic.yml file

  • Set up custom dashboards and alerts in New Relic Insights

  • Monitor application performance metrics like response time, throughput, and error rate

View 1 answer
Frequently asked in

Q22. Difference between intermediate and terminal operations in stream

Ans.

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

View 1 answer
Frequently asked in

Q23. Define Functional interfaces

Ans.

Functional interfaces are interfaces with only one abstract method, used in Java for lambda expressions.

  • Functional interfaces can have multiple default or static methods, but only one abstract method.

  • They are used in Java to enable lambda expressions and method references.

  • Examples of functional interfaces in Java include Runnable, Callable, and Comparator.

Add your answer
Frequently asked in

Q24. what are spring actuators

Ans.

Spring actuators are devices that use the force generated by a spring to move or control a mechanism.

  • Spring actuators convert the potential energy stored in a spring into mechanical motion.

  • They are commonly used in various applications such as valves, switches, and automotive systems.

  • Examples include spring return pneumatic actuators and spring-loaded safety valves.

View 1 answer
Frequently asked in

Q25. What are the groups and view groups

Ans.

Groups and View Groups are components of Android UI that help in organizing and displaying UI elements.

  • View Groups are containers that hold other UI elements, such as LinearLayout, RelativeLayout, etc.

  • Groups are a type of View Group that allow for the creation of complex layouts by grouping multiple UI elements together, such as RadioGroup, TableLayout, etc.

  • Both Groups and View Groups are used to organize and display UI elements in a structured manner.

Add your answer

Q26. Your score is good sql than java?

Ans.

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.

Add your answer

Q27. what is difference between java and java script

Ans.

Java is a programming language used for building applications, while JavaScript is a scripting language primarily used for web development.

  • Java is a statically typed language, while JavaScript is dynamically typed.

  • Java is compiled and runs on the Java Virtual Machine (JVM), while JavaScript is interpreted by the browser.

  • Java is used for building standalone applications, server-side applications, and Android apps, while JavaScript is mainly used for client-side web development...read more

Add your answer
Frequently asked in

Q28. What to choose nodejs or java.

Ans.

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

Add your answer

Q29. what is java and .net

Ans.

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

Add your answer

Q30. write dockerfile for java application.

Ans.

A Dockerfile is a text file that contains instructions for building a Docker image for a Java application.

  • Use a base image that includes Java, such as 'openjdk:8'

  • Copy the application JAR file to the image using the 'COPY' instruction

  • Set the working directory using the 'WORKDIR' instruction

  • Specify the command to run the Java application using the 'CMD' instruction

Add your answer

Q31. Tell us how to call osgi service from model

Ans.

To call an OSGi service from a model, use the service tracker and obtain the service reference.

  • Create a service tracker object

  • Set the context and filter for the service tracker

  • Open the service tracker

  • Get the service reference from the tracker

  • Use the service reference to call the OSGi service

Add your answer

Q32. Where Observer pattern used in SpringBoot?

Ans.

The Observer pattern is used in SpringBoot for implementing event handling and notification mechanisms.

  • The Observer pattern is commonly used in SpringBoot for implementing event listeners and publishers.

  • It allows objects to subscribe to and receive notifications about changes or events in other objects.

  • Spring's ApplicationEvent and ApplicationListener interfaces are examples of the Observer pattern in action.

  • Listeners can be registered with the ApplicationEventPublisher to re...read more

Add your answer

Q33. What is Meta space in Java 8 ?

Ans.

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.

Add your answer

Q34. what is concurrency in java

Ans.

Concurrency in Java refers to the ability of multiple tasks to run simultaneously within a program.

  • Concurrency allows for better utilization of resources by executing multiple tasks at the same time.

  • Java provides built-in support for concurrency through features like threads and thread pools.

  • Concurrency can lead to issues like race conditions and deadlocks, which need to be carefully managed.

  • Example: Running multiple threads to perform different tasks concurrently in a web se...read more

Add your answer
Frequently asked in

Q35. Explain Dependency Injection in spring boot

Ans.

Dependency Injection is a design pattern in Spring Boot where the dependencies of a class are injected from the outside.

  • In Spring Boot, Dependency Injection is achieved through inversion of control, where the control of creating and managing objects is given to the Spring framework.

  • Dependencies can be injected into a class using constructor injection, setter injection, or field injection.

  • By using Dependency Injection, classes become more loosely coupled, making them easier to...read more

Add your answer

Q36. How do handle lazy loading in hibernate

Ans.

Lazy loading in Hibernate is a technique used to load data only when it is needed, improving performance.

  • Lazy loading is achieved by setting the fetch type to LAZY in the mapping of the entity relationship.

  • When an entity is loaded, associated entities marked as LAZY are not loaded until accessed.

  • Lazy loading helps in reducing unnecessary database calls and improves performance.

  • Example: @OneToMany(fetch = FetchType.LAZY)

Add your answer

Q37. How many types of data type in java?

Ans.

There are 8 primitive data types in Java: byte, short, int, long, float, double, char, and boolean.

  • byte - 8-bit signed integer

  • short - 16-bit signed integer

  • int - 32-bit signed integer

  • long - 64-bit signed integer

  • float - 32-bit floating point

  • double - 64-bit floating point

  • char - 16-bit Unicode character

  • boolean - true or false value

Add your answer
Frequently asked in

Q38. Difference between getwindowhandle and getwindowhandles

Ans.

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()

Add your answer
Frequently asked in

Q39. How Kotlin is better than Java.

Ans.

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

Add your answer

Q40. What is abstract method?

Ans.

An abstract method is a method that is declared without an implementation in an abstract class or interface.

  • Abstract methods do not have a body and must be implemented by subclasses.

  • Abstract classes can have both abstract and non-abstract methods.

  • Interfaces can only have abstract methods by default.

Add your answer
Frequently asked in

Q41. Tell me about Executor framework

Ans.

Executor framework is a Java framework that provides a way to execute tasks asynchronously using a thread pool.

  • It provides a way to manage threads and execute tasks in a thread pool

  • It allows for better resource management and improved performance

  • It supports different types of thread pools such as fixed, cached, and scheduled

  • Example: Executors.newFixedThreadPool(10) creates a thread pool with 10 threads

Add your answer

Q42. what is java? and operators in java

Ans.

Java is a high-level, object-oriented programming language used to develop applications for various platforms.

  • Java is platform-independent and can run on any device with a Java Virtual Machine (JVM)

  • Java has a rich set of operators including arithmetic, relational, logical, bitwise, and assignment operators

  • Examples of operators in Java include + (addition), < (less than), && (logical AND), | (bitwise OR), and = (assignment)

Add your answer

Q43. what is java and new features of java

Ans.

Java is a popular programming language known for its platform independence and object-oriented approach. New features include modules, var keyword, and more.

  • Java is a high-level, class-based, object-oriented programming language.

  • New features in Java include modules for better code organization, the var keyword for type inference, and enhancements in the Java Platform Module System (JPMS).

  • Java 14 introduced switch expressions, records, and text blocks as new features.

  • Java 15 a...read more

Add your answer
Frequently asked in

Q44. What is the purpose of using default methods in java8?

Ans.

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

Add your answer

Q45. how to set default value of date field to current date time value

Ans.

To set the default value of a date field to the current date time value, use a script to assign the value.

  • Create a client script or business rule to set the default value

  • Use the GlideDateTime API to get the current date time value

  • Assign the current date time value to the date field

Add your answer
Frequently asked in

Q46. Difference between super and super()

Ans.

super is a keyword used to access methods and properties of a superclass, while super() is used to call the constructor of a superclass.

  • super is used to access methods and properties of a superclass in a subclass.

  • super() is used to call the constructor of a superclass from a subclass constructor.

  • super can be used to access overridden methods or properties in the superclass.

  • super() must be the first statement in a subclass constructor.

Add your answer
Frequently asked in

Q47. What is the use of super keyword ?

Ans.

The super keyword is used in Java to refer to the immediate parent class object.

  • Used to access methods and variables of the parent class

  • Helps in achieving method overriding in inheritance

  • Can be used to call the constructor of the parent class

  • Example: super.methodName();

Add your answer

Q48. WHat is Executor Service

Ans.

Executor Service is a framework provided by Java to manage and control the execution of tasks in a multithreaded environment.

  • It provides a way to manage threads and execute tasks asynchronously.

  • It allows for the reuse of threads instead of creating new ones for each task.

  • It can handle task scheduling, thread pooling, and thread lifecycle management.

  • Example: Executors.newFixedThreadPool(5) creates a thread pool with 5 threads.

Add your answer
Frequently asked in

Q49. explain Wrapper Class in java 8

Ans.

Wrapper class in Java 8 is used to convert primitive data types into objects.

  • Wrapper classes provide a way to use primitive data types as objects.

  • They are used for converting primitive data types into objects and vice versa.

  • Examples include Integer, Double, Boolean, etc.

Add your answer

Q50. What is parallel stream

Ans.

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

Add your answer
Frequently asked in

Q51. Explain what is Spring Sleuth

Ans.

Spring Sleuth is a distributed tracing system for microservices built on top of Spring Cloud.

  • Spring Sleuth helps in tracking and monitoring requests as they travel through different microservices.

  • It generates unique trace and span IDs for each request to help in correlating logs and metrics.

  • Spring Sleuth integrates with Zipkin, a distributed tracing system, to provide visualization of request flows.

  • It is commonly used in microservices architectures to troubleshoot performance...read more

Add your answer

Q52. What is a Spring Actuator?

Ans.

Spring Actuator is a feature in Spring Boot that allows monitoring and managing the application.

  • Spring Actuator provides endpoints to monitor application health, metrics, info, etc.

  • It helps in understanding the internal state of the application and its performance.

  • Actuator endpoints can be accessed over HTTP, providing useful information for monitoring tools.

  • Example: /actuator/health, /actuator/metrics, /actuator/info

Add your answer
Frequently asked in

Q53. Which Java framework you are more familiar with?

Ans.

I am more familiar with the Spring framework in Java.

  • I have extensive experience working with Spring Boot for building microservices.

  • I have used Spring MVC for developing web applications.

  • I am proficient in using Spring Data JPA for database interactions.

  • I have worked with Spring Security for implementing authentication and authorization.

  • I am familiar with Spring Cloud for building cloud-native applications.

Add your answer

Q54. What is java and used in java beans

Ans.

Java is a programming language used for developing applications. JavaBeans are reusable software components for Java.

  • Java is an object-oriented language

  • JavaBeans are reusable software components

  • JavaBeans can be used to create GUI components

  • JavaBeans can be used in web applications

  • JavaBeans can be used in enterprise applications

Add your answer

Q55. What are Java8 streams

Ans.

Java8 streams are a sequence of elements that support functional-style operations.

  • Streams allow for processing sequences of elements in a functional way

  • They can be created from collections, arrays, or other sources

  • Operations like map, filter, reduce can be applied to streams

  • Streams are lazy, meaning they only process elements when needed

  • Example: List names = Arrays.asList("Alice", "Bob", "Charlie"); Stream stream = names.stream();

Add your answer
Frequently asked in

Q56. what is Component Scan

Ans.

Component Scan is a feature in Spring framework that automatically scans and registers Spring components in the application context.

  • Component Scan is used to automatically detect and register Spring components like @Component, @Service, @Repository, and @Controller.

  • It eliminates the need for manual configuration of bean definitions in the Spring configuration file.

  • Component Scan can be configured with base package(s) to scan for components.

  • Example: @ComponentScan(basePackages...read more

Add your answer

Q57. Web development framework of jaba

Ans.

Java web development frameworks include Spring, Hibernate, Struts, and Play.

  • Popular Java web development frameworks include Spring, Hibernate, Struts, and Play

  • Spring is a widely used framework for building enterprise Java applications

  • Hibernate is an ORM framework for mapping Java objects to database tables

  • Struts is a framework for building web applications using the MVC design pattern

  • Play is a lightweight web framework for building scalable web applications

Add your answer
Frequently asked in

Q58. Database 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 scalability, performance, and data structure requirements.

  • For example, a Java front end developer working on a financial application may use Oracle for its robust transaction capabilities.

Add your answer

Q59. Internal working of Java Hash Map

Ans.

Java HashMap is a data structure that stores key-value pairs and uses hashing to efficiently retrieve values.

  • HashMap uses an array of buckets to store key-value pairs.

  • The key is hashed to find the index of the bucket where the value is stored.

  • If multiple keys hash to the same index, a linked list or balanced tree is used to handle collisions.

  • HashMap allows one null key and multiple null values.

  • Example: HashMap map = new HashMap<>();

Add your answer
Frequently asked in

Q60. spring boot starter use

Ans.

Spring Boot starters are dependency descriptors that simplify the dependency management process in Spring Boot applications.

  • Spring Boot starters provide a set of pre-configured dependencies that can be easily included in your project.

  • They help in reducing the amount of boilerplate code needed to set up a Spring Boot application.

  • Starters are typically named with the format 'spring-boot-starter-*', where * represents the specific functionality or technology being included.

  • For e...read more

Add your answer

Q61. @functionalinterface can we extend or not, map &amp; flatmap

Ans.

No, @FunctionalInterface cannot be extended. Map and flatMap are default methods in the interface and cannot be overridden.

  • No, @FunctionalInterface cannot be extended as it is a single abstract method interface.

  • Map and flatMap are default methods in the interface and cannot be overridden.

  • Example: public interface MyInterface { void myMethod(); default void myDefaultMethod() { // implementation } }

Add your answer
Frequently asked in

Q62. Java 8 in depth

Ans.

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.

Add your answer

Q63. Design principles in Java.

Ans.

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

Add your answer

Q64. Java 8 advantages

Ans.

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

  • Lambda expressions allow for more concise and readable code.

  • Functional interfaces enable the use of lambda expressions.

  • Streams provide a way to work with collections in a more functional style.

  • Default methods allow interfaces to have method implementations.

Add your answer
Frequently asked in

Q65. Spring java and how do you leverage in your project

Ans.

I leverage Spring Java for dependency injection, MVC framework, and transaction management in my projects.

  • Utilize Spring's dependency injection to manage object dependencies and improve code maintainability

  • Leverage Spring MVC framework for building web applications with clean separation of concerns

  • Use Spring's transaction management to ensure data integrity and consistency in database operations

Add your answer
Frequently asked in

Q66. 1 What’s functional interface and benefits. 2 Transaction uses and different propagation level.

Ans.

Functional interface is an interface with only one abstract method. Benefits include lambda expressions and improved code readability.

  • Functional interface allows for the use of lambda expressions, which can simplify code and improve readability.

  • It also enables the use of method references, which can make code more concise.

  • Functional interfaces are used extensively in Java 8's Stream API.

  • Transaction uses include ensuring data consistency and atomicity.

  • Propagation levels includ...read more

Add your answer

Q67. Different technologies available in java

Ans.

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

Add your answer
Frequently asked in

Q68. Hopq to deploy java aps

Ans.

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

Add your answer

Q69. JPA vs Hibernate

Ans.

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

Add your answer
Frequently asked in

Q70. 1 Write a procedure using user defined exception 2 write a procedure to get error, if updating end of the month. Etc....

Ans.

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

Add your answer
Frequently asked in

Q71. All Java 8 new features

Ans.

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

Add your answer
Frequently asked in

Q72. AWT Token working

Ans.

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

Add your answer

Q73. Spring JPA vs Hibernate

Ans.

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

Add your answer

Q74. Implementation of database connection pool in java

Ans.

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.

Add your answer
Frequently asked in

Q75. Concurrent package: internal working of CopyOnWriteArrayList Diff between synchronized collection and concurrent collection

Ans.

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

Add your answer
Frequently asked in

Q76. 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 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.

Add your answer
Frequently asked in

Q77. 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 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.

Add your answer

Q78. 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 functional style.

  • Functional interfaces like Predicate, Function, and Consumer are commonly used with lambda expressions.

Add your answer

Q79. 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 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.

Add your answer
Frequently asked in

Q80. 4) How to send the values without using 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 JavaScriptExecutor to set the value.

  • Example: driver.executeScript("document.getElementById('elementId').value='text'");

View 2 more answers

Q81. Difference between @Inject and @Autowire

Ans.

Difference between @Inject and @Autowire in Java Spring

  • Both are used for dependency injection in Spring framework

  • @Inject is a standard annotation defined in Java EE, while @Autowired is a Spring-specific annotation

  • @Inject is more powerful and flexible as it supports optional dependencies and custom qualifiers

  • @Autowired is more commonly used in Spring applications and is more concise

Add your answer

Q82. Explain package

Ans.

A package is a way to organize related classes and interfaces in Java.

  • Packages help in organizing code and avoiding naming conflicts

  • Packages can be nested within each other

  • Packages are declared using the 'package' keyword at the beginning of a Java file

Add your answer
Frequently asked in

Q83. What @SpringBootApplication will do

Ans.

@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

Add your answer

Q84. What is the different technique to inject bean in application context

Ans.

Different techniques for injecting beans in application context

  • Constructor Injection

  • Setter Injection

  • Field Injection

  • Method Injection

Add your answer
Frequently asked in

Q85. 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 with lambda expressions.

  • Streams provide a way to work with sequences of elements and perform aggregate operations.

  • Default methods allow interfaces to have method implementations.

Add your answer

Q86. what is c+,c++ what is java

Ans.

C+ and C++ are programming languages used for system and application development, while Java is a high-level programming language known for its portability and versatility.

  • C+ and C++ are low-level programming languages used for system programming and application development.

  • C++ is an extension of the C programming language with added features like classes and objects.

  • Java is a high-level programming language known for its portability and versatility, often used for web develo...read more

Add your answer
Frequently asked in

Q87. Name some methods in Executor framework?

Ans.

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

Add your answer

Q88. difference between the @controller vs @restcontroller

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 traditional web requests.

  • The @RestController annotation is used to create RESTful web services, which return data in JSON or XML format.

  • The @RestController annotation is a specialized version of the @Controller annotation that includes t...read more

Add your answer
Frequently asked in

Q89. 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, @Repository

  • Annotations help in reducing XML configuration and make code more readable and maintainable

Add your answer

Q90. What are all the features of java 8

Ans.

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 and perform operations on them.

  • Default methods allow interfaces to have methods with implementation.

  • Other features include the new D...read more

Add your answer

Q91. Difference between findFirst and findAny

Ans.

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

Add your answer

Q92. Tell me about what is completable future

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 operations.

  • It provides methods like thenApply, thenCompose, thenCombine, etc. for combining results.

  • Example: CompletableFuture future = CompletableFuture.supplyAsync(() -> 10);

View 1 answer
Frequently asked in

Q93. No Java is not 100 % Object Oriented, its datatypes are not objects

Ans.

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.

Add your answer
Frequently asked in

Q94. Difference between findElements and findElement?

Ans.

findElements returns a list of web elements matching the locator, while findElement returns the first web element matching the locator.

  • findElements returns a list of web elements, findElement returns the first element

  • findElements returns an empty list if no elements are found, findElement throws NoSuchElementException

  • findElements is useful for finding multiple elements, findElement is useful for finding a single element

Add your answer
Frequently asked in

Q95. What is react and different between java are react

Ans.

React is a JavaScript library for building user interfaces, while Java is a programming language.

  • React is a JavaScript library developed by Facebook for building user interfaces.

  • Java is a programming language that is used for developing a wide range of applications.

  • React uses a virtual DOM for efficient updates, while Java is a statically typed language.

  • React is mainly used for front-end development, while Java can be used for both front-end and back-end development.

  • React com...read more

Add your answer

Q96. What is java and pattern question?

Ans.

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.

Add your answer

Q97. Why do we have @functionalInterface if we can make any interface as functional interface if it already has one abstract method?

Ans.

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

Add your answer

Q98. Explaing colletion framework

Ans.

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.

Add your answer

Q99. Characters finding using Stream Api

Ans.

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

Add your answer
Frequently asked in

Q100. What are functional Interfaces?

Ans.

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.

Add your answer
Frequently asked in
1
2
3
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories

Interview experiences of popular companies

3.7
 • 10.3k Interviews
3.9
 • 8.1k Interviews
3.7
 • 7.6k Interviews
3.7
 • 5.6k Interviews
3.8
 • 5.5k Interviews
3.8
 • 4.8k Interviews
3.5
 • 3.8k Interviews
3.5
 • 3.8k Interviews
3.8
 • 3k Interviews
4.0
 • 2.4k Interviews
View all
Java Interview Questions
Share an Interview
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
70 Lakh+

Reviews

5 Lakh+

Interviews

4 Crore+

Salaries

1 Cr+

Users/Month

Contribute to help millions
Get AmbitionBox app

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

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter