Java
Top 250 Java Interview Questions and Answers 2024
250 questions found
Updated 14 Dec 2024
Q1. What is javaa and when it developed
Java is a high-level, class-based, object-oriented programming language developed by Sun Microsystems in 1995.
Java is platform-independent and can run on any device with a Java Virtual Machine (JVM)
It is widely used for developing web, mobile, and desktop applications
Java has a vast library of pre-built classes and APIs
Java is constantly evolving with new versions and updates
Examples of popular Java-based applications include Minecraft, Android OS, and Hadoop
Q2. Write a short code in java or C
Code to find the factorial of a number
Use a loop to multiply the number with all the numbers below it
Handle the case when the number is 0 or 1 separately
Use long data type to handle large factorials
Q3. What's the difference between java and c++?
Java is an object-oriented language with automatic memory management, while C++ is a compiled language with manual memory management.
Java is platform-independent, while C++ is platform-dependent.
Java has a simpler syntax and is easier to learn, while C++ is more complex and difficult to master.
Java has built-in garbage collection, while C++ requires manual memory management.
Java is used for developing web applications, mobile apps, and enterprise software, while C++ is used f...read more
Q4. do @requestparam has default value
Yes, @RequestParam has a default value if not specified.
If a @RequestParam is not provided in the request, it will use its default value.
The default value can be set using the 'defaultValue' attribute of @RequestParam annotation.
If no default value is specified, the parameter will be considered as required and an exception will be thrown if not provided.
Q5. Why python is differ from Java?
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
Q6. What are the java8 features
Java8 features include lambda expressions, functional interfaces, streams, and default methods.
Lambda expressions allow 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 way.
Default methods allow interfaces to have method implementations.
Other features include the Date and Time API, Nashorn JavaScript engine, and improved security.
Q7. 9. What is @SpringBootApplication?
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); } }
Q8. What is different between Java and html
Java is a programming language while HTML is a markup language used for creating web pages.
Java is used for developing applications while HTML is used for creating web pages.
Java is an object-oriented language while HTML is not.
Java requires a compiler to convert code into bytecode while HTML does not require any compilation.
Java can be used for creating standalone applications while HTML cannot.
Java can be used for creating dynamic web pages while HTML is used for creating s...read more
Java Jobs
Q9. Why use in java to Javascript
Java and JavaScript are two different programming languages with different use cases.
Java is used for building server-side applications, Android apps, and enterprise software.
JavaScript is used for building interactive web applications and front-end development.
Java is a compiled language while JavaScript is an interpreted language.
Java is statically typed while JavaScript is dynamically typed.
Java code runs on the Java Virtual Machine (JVM) while JavaScript code runs on web ...read more
Q10. What are Features of Java 8
Java 8 introduced several new features including lambda expressions, functional interfaces, and streams.
Lambda expressions for functional programming
Functional interfaces for defining functions
Streams for processing collections
Default methods for backward compatibility
Date and time API improvements
Nashorn JavaScript engine
Parallel array sorting
Type annotations
Repeatable annotations
Q11. How many ways to create the object in java
There are multiple ways to create objects in Java.
Using the 'new' keyword
Using object cloning
Using object deserialization
Using reflection
Using factory methods
Using dependency injection frameworks
Q12. Can we use static method in an interface.
Yes, static methods can be used in an interface.
Static methods in an interface can be used to provide utility methods that are not tied to any specific instance of the interface.
These methods can be called directly on the interface itself, without the need for an instance of a class that implements the interface.
Static methods in an interface cannot be overridden by implementing classes.
They can be useful for providing common functionality or helper methods that are related t...read more
Q13. Difference between Spring IOC and Dependency Injection
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
Q14. Do you know Java,.NET,etc?
Yes, I am familiar with Java and .NET.
I have experience working with Java and .NET programming languages.
I have developed applications using Java and .NET frameworks.
I am proficient in writing code, debugging, and troubleshooting in Java and .NET.
I am familiar with object-oriented programming concepts in Java and .NET.
I have used Java and .NET to build web applications, desktop applications, and mobile apps.
Q15. Difference between runnable and callable interface?
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
Q16. what is the difference between stream and parallel stream
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
Q17. can we use lambda expression without functional interface
No, lambda expressions can only be used with functional interfaces.
Lambda expressions are used to implement functional interfaces.
Functional interfaces have only one abstract method.
Lambda expressions provide a concise way to implement the abstract method of a functional interface.
If a lambda expression is used without a functional interface, it will result in a compilation error.
Q18. Explain how Java program execute?
Java programs are executed by the Java Virtual Machine (JVM) which interprets and executes the bytecode generated by the Java compiler.
Java source code is compiled into bytecode by the Java compiler
The bytecode is platform-independent and can be executed on any device with a JVM
The JVM interprets the bytecode and executes the instructions
The JVM manages memory, handles exceptions, and provides other runtime services
Example: javac HelloWorld.java -> java HelloWorld
Q19. What are the groups and view groups
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.
Q20. what is java? what is sql? etc
Java is a programming language used for developing applications. SQL is a language used for managing relational databases.
Java is an object-oriented language
Java code is compiled into bytecode
SQL is used for creating, modifying, and querying databases
SQL is used in various database management systems like MySQL, Oracle, etc.
Q21. why should we use nodejs has over java
Node.js is faster, more scalable, and easier to learn than Java.
Node.js is built on Chrome's V8 JavaScript engine, which is faster than Java's JVM.
Node.js uses an event-driven, non-blocking I/O model, making it more scalable than Java.
Node.js has a simpler and more intuitive syntax, making it easier to learn than Java.
Node.js has a large and active community, with many open-source libraries and frameworks available.
Java is better suited for large enterprise applications with ...read more
Q22. what design pattern are there in java and on which pattern have you worked.
Java has several design patterns such as Singleton, Factory, Observer, Decorator, etc.
Singleton pattern ensures that only one instance of a class is created
Factory pattern provides an interface for creating objects in a superclass, but allows subclasses to alter the type of objects that will be created
Observer pattern defines a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically
Decorator patte...read more
Q23. Explain java methods
Java methods are blocks of code that perform a specific task and can be called upon to execute that task.
Methods are declared within a class and can be public, private, or protected.
They can take parameters and return values.
Methods can be overloaded, meaning there can be multiple methods with the same name but different parameters.
Example: public void printMessage(String message) { System.out.println(message); }
Q24. 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
Q25. WAP to collect all even no in list using stream API
WAP to collect all even no in list using stream API
Use stream() method to convert list to stream
Use filter() method to filter even numbers
Use collect() method to collect filtered numbers into a list
Q26. Why is kotlin used rather than Java
Kotlin is used over Java due to its concise syntax, null safety, and interoperability with Java.
Kotlin has a more concise syntax than Java, making it easier to read and write.
Kotlin has built-in null safety features, reducing the risk of null pointer exceptions.
Kotlin is fully interoperable with Java, allowing developers to use both languages in the same project.
Kotlin also offers features such as extension functions, data classes, and coroutines, which can improve code quali...read more
Q27. What is completableFuture?
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);
Q28. How to implement word suggestions like that in Eclipse
Word suggestions in Eclipse can be implemented using algorithms like Trie or N-gram models.
Use Trie data structure to store the dictionary of words
Implement auto-complete feature using Trie
Use N-gram models to suggest words based on context
Train the N-gram model on a large corpus of text data
Combine both approaches for better accuracy
Consider user's typing speed and frequency of words for better suggestions
Q29. Difference between @Bean, @Component
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
Q30. String s="Expense is 1000 rs"..Extract 1000 from the above string and add 100 to it, print it like Expense is 1100
Extract and manipulate numerical value from a string.
Use regular expressions to extract the numerical value from the string.
Convert the extracted value to an integer, add 100 to it, and then format it back into the original string format.
Print the updated string with the new numerical value.
Q31. 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
Q32. What project you done in java?
Developed a web-based inventory management system using Java, Spring Boot, and MySQL.
Utilized Java for backend logic and Spring Boot for RESTful API development.
Implemented user authentication and authorization using Spring Security.
Integrated MySQL database for storing and retrieving inventory data.
Designed a user-friendly web interface using HTML, CSS, and JavaScript.
Q33. Find java elements in selenium
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.
Q34. Explain any Java frameworks you have used
I have experience with Spring, Hibernate, and Apache Struts frameworks in Java development.
Used Spring framework for dependency injection and MVC architecture
Utilized Hibernate for ORM mapping and database interaction
Worked with Apache Struts for building web applications
Q35. 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
Q36. Class A{int num=60;} Class B extends A{int num=100; main(){ A a=new B; Sop(a.num);//output}}
Output of a Java program that extends a class and overrides a variable
Class B extends Class A and overrides the variable num with a value of 100
In the main method, an object of Class B is created and assigned to a reference variable of Class A
When the value of num is accessed using the reference variable, the output will be 60 as it is the value of num in Class A
Q37. 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.
Q38. what is concurrency in java
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
Q39. What’s is the use of functional interface
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.
Q40. Explain the collection framework
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);
Q41. How do you monitor java app newrelic
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
Q42. Difference between getWindowHandles and getWindowHandle
getWindowHandles returns all open window handles, getWindowHandle returns handle of current window
getWindowHandles returns a set of all window handles currently open in the browser
getWindowHandle returns the handle of the current window being focused on
Example: driver.getWindowHandles() vs driver.getWindowHandle()
Q43. 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
Q44. What is Java compiler?
Java compiler is a program that converts Java code into bytecode that can be executed on any platform.
Java compiler is a part of the Java Development Kit (JDK).
It checks the syntax of the code and generates bytecode.
The bytecode can be executed on any platform that has a Java Virtual Machine (JVM).
The compiler can be run from the command line or integrated into an IDE like Eclipse or IntelliJ.
Example: javac HelloWorld.java will compile the code in the file HelloWorld.java.
Q45. 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.
Q46. -Difference between stream and parallel stream.
Stream is sequential processing while parallel stream allows for parallel processing.
Stream processes elements sequentially
Parallel stream processes elements concurrently
Parallel stream can improve performance for large datasets
Example: List
list = Arrays.asList("a", "b", "c"); Stream stream = list.stream(); Stream parallelStream = list.parallelStream();
Q47. 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
Q48. What is your experience in Java or Angular
I have extensive experience in both Java and Angular.
I have worked on multiple projects using Java and Angular.
I am proficient in developing web applications using Angular.
I have experience in developing RESTful web services using Java.
I have worked with various Java frameworks such as Spring and Hibernate.
I have experience in using Angular Material for UI development.
I have knowledge of TypeScript and JavaScript.
I have experience in using Git for version control.
Q49. What is java and explain it's concepts.
Java is a high-level programming language known for its portability, security, 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 the creation of reusable code through classes and objects.
Java is known for its security features, such as sandboxing and encryption.
It supports multithreading, allowing for concurrent execution of multiple tasks.
Java has a rich standard l...read more
Q50. explain C# vs Java
C# is a Microsoft-developed language with strong typing and object-oriented features, while Java is a platform-independent language with a large ecosystem.
C# is primarily used for Windows development, while Java is platform-independent and can run on any system with Java Virtual Machine (JVM)
C# has a simpler syntax compared to Java, making it easier to learn for beginners
Java has a larger ecosystem with more libraries and frameworks available compared to C#
C# is closely integ...read more
Q51. Why java is not said as pure OOPs language?
Java is not considered a pure OOP language because it supports primitive data types and allows for procedural programming.
Java supports primitive data types like int, double, and boolean which are not objects.
Java allows for procedural programming with features like static methods and variables.
In pure OOP languages like Smalltalk, everything is an object and there are no primitive data types or procedural features.
Q52. Describe experiences in java/j2ee technologies
Experienced in developing Java/J2EE applications with Spring framework and Hibernate ORM.
Developed RESTful web services using Spring Boot for efficient communication between client and server.
Utilized Hibernate ORM for database interaction, ensuring data integrity and security.
Worked on implementing security features like authentication and authorization using Spring Security.
Used JSP and Servlets for dynamic web page generation and user interaction.
Integrated third-party API...read more
Q53. write dockerfile for java application.
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
Q54. What are the alternatives for java collections in some other programming languages
Some alternatives for Java collections in other programming languages include Python's lists, C++'s vectors, and JavaScript's arrays.
Python: lists
C++: vectors
JavaScript: arrays
Q55. Is there experience in Javafullstack?
Yes, I have experience in Java full stack development.
Developed full stack applications using Java technologies such as Spring Boot, Hibernate, and JSP/Thymeleaf for frontend
Worked on integrating frontend and backend components to create a seamless user experience
Utilized RESTful APIs for communication between frontend and backend systems
Q56. Tell us how to call osgi service from model
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
Q57. Where Observer pattern used in SpringBoot?
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
Q58. Write a code to explain method overriding.
Method overriding is when a subclass provides a specific implementation of a method that is already provided by its parent class.
In method overriding, the method in the subclass has the same name, return type, and parameters as the method in the parent class.
The overridden method in the subclass should have the same or broader access modifier than the method in the parent class.
Example: class Animal { void sound() { System.out.println('Animal sound'); } } class Dog extends An...read more
Q59. Explain Dependency Injection in spring boot
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
Q60. How do handle lazy loading in hibernate
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)
Q61. explain packages in java
Packages in Java are used to organize classes and interfaces into namespaces for better code organization and reusability.
Packages help in avoiding naming conflicts by grouping related classes together.
Packages can be nested within each other to create a hierarchical structure.
Packages are declared using the 'package' keyword at the beginning of a Java file.
Example: 'package com.example.myapp;' declares a package named 'com.example.myapp'.
Q62. Difference between loops in java 7 and loops in streams
Loops in Java 7 vs Loops in Streams
Java 7 loops use imperative programming style, while streams use functional programming style
Java 7 loops require explicit iteration, while streams handle iteration internally
Streams provide built-in methods for filtering, mapping, and reducing data
Streams can be parallelized for improved performance
Java 7 loops are generally more efficient for simple iterations
Q63. What is mutable classes in java? How to create?
Mutable classes in Java are classes whose state can be modified after creation.
Mutable classes allow changing their internal state
They can have mutable fields or methods that modify their state
To create a mutable class, define fields with non-final modifiers
Provide public methods to modify the state of the class
Q64. What is abstract method?
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.
Q65. Tell me about Executor framework
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
Q66. Difference between lambda and method reference.
Lambda is an anonymous function while method reference refers to an existing method.
Lambda expressions are used to create anonymous functions that can be passed as arguments to methods or stored in variables.
Method references are used to refer to an existing method by name instead of defining a new lambda expression.
Lambda expressions are more flexible and can be used to create functions with any number of parameters, while method references can only refer to methods with mat...read more
Q67. When would Java be used over C/C++?
Java is used over C/C++ when platform independence, ease of use, and security are important.
Java is platform independent, meaning it can run on any operating system or hardware that has a Java Virtual Machine (JVM). C/C++ code needs to be compiled separately for each platform.
Java has automatic memory management, reducing the risk of memory leaks and making it easier to write and maintain code. C/C++ requires manual memory management.
Java has built-in security features, such ...read more
Q68. what is java? and operators in java
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)
Q69. what is java and new features of java
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
Q70. how to set default value of date field to current date time value
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
Q71. Difference between super and super()
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.
Q72. What is the use of super keyword ?
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();
Q73. What question you will put to a java professional for analysing his/her skill
What is the difference between an abstract class and an interface in Java?
Ask about the purpose of each
Ask about the implementation details
Ask about the number of inheritance allowed
Ask about the use of access modifiers
Ask about the use of default methods
Ask about the use of static methods
Ask about the use of variables
Q74. What is Java 8 stream
Java 8 stream is a sequence of elements that supports functional-style operations.
Java 8 stream allows for processing collections of objects in a functional way.
Streams can be created from various data sources like collections, arrays, or I/O resources.
Common stream operations include map, filter, reduce, and collect.
Streams are lazy, meaning they only perform operations when necessary.
Example: List
names = Arrays.asList("Alice", "Bob", "Charlie"); Stream stream = names.strea...read more
Q75. Explain method references in Java 8
Method references in Java 8 are a way to refer to methods or constructors without invoking them directly.
Method references are shorthand notation for lambda expressions.
They can be used to make code more concise and readable.
There are four types of method references: static, instance, constructor, and arbitrary object.
Example: list.forEach(System.out::println);
Q76. WHat is Executor Service
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.
Q77. explain Wrapper Class in java 8
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.
Q78. what are spring actuators
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.
Q79. Does Java has interpreter or compiler?
Java has both interpreter and compiler.
Java uses both interpreter and compiler. The Java compiler converts Java code into bytecode, which is then interpreted by the Java Virtual Machine (JVM).
The compiler translates Java source code into bytecode (.class files), which can be executed by the JVM.
The interpreter reads and executes the bytecode instructions line by line at runtime.
This combination of compiler and interpreter allows Java to be platform-independent and enables fea...read more
Q80. Explain what is Spring Sleuth
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
Q81. What is a Spring Actuator?
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
Q82. Which Java framework you are more familiar with?
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.
Q83. What is java and used in java beans
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
Q84. What are Java8 streams
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();
Q85. what is Component Scan
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
Q86. 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
Q87. 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.
Q88. Java program on all data structures
Java program on all data structures
Start by implementing basic data structures like arrays, linked lists, stacks, queues, trees, and graphs
Use Java built-in classes like ArrayList, LinkedList, Stack, Queue, TreeMap, and HashMap
Practice implementing algorithms like sorting, searching, and traversal on these data structures
Q89. spring boot starter use
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
Q90. @functionalinterface can we extend or not, map & flatmap
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 } }
Q91. OOPS principles in Java
OOPS principles in Java focus on encapsulation, inheritance, polymorphism, and abstraction.
Encapsulation: Bundling data and methods that operate on the data into a single unit.
Inheritance: Allows a class to inherit properties and behavior from another class.
Polymorphism: Ability to present the same interface for different data types.
Abstraction: Hiding the implementation details and showing only the necessary features.
Q92. Internal working of Java Hash Map
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<>();
Q93. java 8 new added features
Java 8 introduced several new features including lambda expressions, streams, functional interfaces, and default methods.
Lambda expressions allow you to write code in a more concise and readable way.
Streams provide a new way to work with collections in a functional style.
Functional interfaces are interfaces with a single abstract method, enabling the use of lambda expressions.
Default methods allow interfaces to have method implementations.
Some other features include the new D...read more
Q94. Tools that are used in java development.
Various tools used in Java development include IDEs, build tools, version control systems, and testing frameworks.
IDEs: Eclipse, IntelliJ IDEA, NetBeans
Build tools: Maven, Gradle, Ant
Version control systems: Git, SVN, Mercurial
Testing frameworks: JUnit, TestNG, Mockito
Q95. Java design principles
Java design principles are guidelines for writing efficient, maintainable, and scalable code.
Single Responsibility Principle (SRP)
Open/Closed Principle (OCP)
Liskov Substitution Principle (LSP)
Interface Segregation Principle (ISP)
Dependency Inversion Principle (DIP)
Q96. Java 8 advantages
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.
Q97. Features of java. Basic concepts of java
Java is a popular programming language known for its platform independence and object-oriented features.
Object-oriented programming
Platform independence
Garbage collection
Exception handling
Multithreading
Java Virtual Machine (JVM)
Java Development Kit (JDK)
Application Programming Interface (API)
Q98. Bean injection if there is ambiguity
Bean injection is a technique used in Spring framework to resolve ambiguity when multiple beans of the same type are available.
Bean injection can be resolved using @Qualifier annotation to specify the bean name to be injected.
Alternatively, you can use @Primary annotation to indicate the primary bean to be injected.
You can also use @Autowired with the bean name as a parameter to specify the bean to be injected.
Q99. 1 What’s functional interface and benefits. 2 Transaction uses and different propagation level.
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
Q100. 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
Top Interview Questions for Related Skills
Interview Questions of Java Related Designations
Interview experiences of popular companies
Reviews
Interviews
Salaries
Users/Month