Java
Skill
Programming Language
Top 250 Java Interview Questions and Answers 2024
250 questions found
Updated 30 Nov 2024
Q1. What is javaa and when it developed
Ans.
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
Add your answer
Frequently asked in
Q2. Write a short code in java or C
Ans.
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
View 1 answer
Frequently asked in
Q3. What's the difference between java and c++?
Ans.
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 u...
read more
View 1 answer
Frequently asked in
Q4. do @requestparam has default value
Ans.
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.
Add your answer
Frequently asked in
Are these interview questions helpful?
Q5. 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
Q6. What are the java8 features
Ans.
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.
Add your answer
Frequently asked in
Share interview questions and help millions of jobseekers 🌟
Q7. 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
Q8. Why use in java to Javascript
Ans.
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 o...
read more
Add your answer
Frequently asked in
Java Jobs
Automation Testing with java, JavaScript , BDD, Selenium • 6-9 years
Cognizant
•
3.8
Hyderabad / Secunderabad
Developer Associate- JavaScript, Java • 1-3 years
SAP India Pvt.Ltd
•
4.2
₹ 10 L/yr - ₹ 24 L/yr
(AmbitionBox estimate)
Bangalore / Bengaluru
Java / JavaScript Automation Lead • 8-12 years
InfoBeans Technologies Limited
•
3.7
Indore
Q9. What are Features of Java 8
Ans.
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
Add your answer
Frequently asked in
Q10. How many ways to create the object in java
Ans.
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
View 1 answer
Q11. Can we use static method in an interface.
Ans.
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 rela...
read more
View 1 answer
Q12. 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
Q13. Do you know Java,.NET,etc?
Ans.
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.
View 1 answer
Q14. 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() { pub...
read more
Add your answer
Q15. 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
Q16. can we use lambda expression without functional interface
Ans.
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.
Add your answer
Frequently asked in
Q17. Explain how Java program execute?
Ans.
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
View 1 answer
Frequently asked in
Q18. 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
Q19. what is java? what is sql? etc
Ans.
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.
Add your answer
Q20. why should we use nodejs has over java
Ans.
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...
read more
Add your answer
Q21. what design pattern are there in java and on which pattern have you worked.
Ans.
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 ...
read more
Add your answer
Frequently asked in
Q22. Explain java methods
Ans.
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); }
Add your answer
Q23. what is java & datatypes
Ans.
Java is a popular programming language used for developing applications. Data types in Java define the type of data that a variable can hold. Java is an object-oriented programming language. Data types in Java include int, double, boolean, and String. Each data type has a specific range of values it can hold. Variables in Java must be declared with a specific data type before use.
Add your answer
Frequently asked in
Q24. WAP to collect all even no in list using stream API
Ans.
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
Add your answer
Q25. Why is kotlin used rather than Java
Ans.
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 ...
read more
Add your answer
Q26. 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
Q27. How to implement word suggestions like that in Eclipse
Ans.
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
Add your answer
Q28. 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 whic...
read more
Add your answer
Q29. String s="Expense is 1000 rs"..Extract 1000 from the above string and add 100 to it, print it like Expense is 1100
Ans.
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.
View 2 more answers
Q30. Tell me spring boot Annotation?
Ans.
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 S...
read more
Add your answer
Frequently asked in
Q31. What project you done in java?
Ans.
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.
Add your answer
Frequently asked in
Q32. What is different between Java and html
Ans.
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 crea...
read more
Add your answer
Q33. 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
Q34. Explain any Java frameworks you have used
Ans.
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
View 1 answer
Q35. 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 component...
read more
Add your answer
Q36. Class A{int num=60;} Class B extends A{int num=100; main(){ A a=new B; Sop(a.num);//output}}
Ans.
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
Add your answer
Frequently asked in
Q37. 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
Q38. What is Java concurrency?
Ans.
Java concurrency refers to the ability of multiple threads to execute simultaneously in a Java program. Java concurrency allows for efficient utilization of resources by running multiple tasks concurrently. It involves concepts like threads, synchronization, locks, and atomic variables. Examples include using the 'synchronized' keyword to protect critical sections of code from concurrent access.
Add your answer
Q39. 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
Q40. 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
Q41. Difference between getWindowHandles and getWindowHandle
Ans.
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()
Add your answer
Frequently asked in
Q42. 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 reduci...
read more
Add your answer
Q43. What is Java compiler?
Ans.
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.ja...
read more
Add your answer
Q44. 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
Q45. -Difference between stream and parallel stream.
Ans.
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();
Add your answer
Frequently asked in
Q46. What is your experience in Java or Angular
Ans.
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.
Add your answer
Q47. What is java and explain it's concepts.
Ans.
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 stan...
read more
Add your answer
Frequently asked in
Q48. explain C# vs Java
Ans.
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 ...
read more
Add your answer
Q49. Why java is not said as pure OOPs language?
Ans.
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.
Add your answer
Frequently asked in
Q50. Describe experiences in java/j2ee technologies
Ans.
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-par...
read more
Add your answer
Q51. 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
Q52. What are the alternatives for java collections in some other programming languages
Ans.
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
Add your answer
Q53. Is there experience in Javafullstack?
Ans.
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
Add your answer
Frequently asked in
Q54. 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
Q55. 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 ...
read more
Add your answer
Q56. Write a code to explain method overriding.
Ans.
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 extend...
read more
Add your answer
Frequently asked in
Q57. 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 easie...
read more
Add your answer
Q58. 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
Q59. explain packages in java
Ans.
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'.
Add your answer
Frequently asked in
Q60. Difference between loops in java 7 and loops in streams
Ans.
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
Add your answer
Q61. What is mutable classes in java? How to create?
Ans.
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
Add your answer
Q62. 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
Q63. 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
Q64. Difference between lambda and method reference.
Ans.
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...
read more
Add your answer
Q65. When would Java be used over C/C++?
Ans.
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, s...
read more
Add your answer
Frequently asked in
Q66. 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),
Add your answer
Q67. 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...
read more
Add your answer
Frequently asked in
Q68. 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
Q69. 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
Q70. 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
Q71. What question you will put to a java professional for analysing his/her skill
Ans.
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
Add your answer
Q72. What is Java 8 stream
Ans.
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...
read more
Add your answer
Q73. Explain method references in Java 8
Ans.
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);
Add your answer
Frequently asked in
Q74. 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
Q75. 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
Q76. 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.
Add your answer
Frequently asked in
Q77. Does Java has interpreter or compiler?
Ans.
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 enable...
read more
Add your answer
Q78. 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 perfor...
read more
Add your answer
Q79. 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
Q80. 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
Q81. 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 resp...
read more
Add your answer
Q82. 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
Q83. 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
Q84. 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(basePac...
read more
Add your answer
Q85. 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
Q86. 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
Q87. Java program on all data structures
Ans.
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
Add your answer
Frequently asked in
Q88. 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. ...
read more
Add your answer
Q89. @functionalinterface can we extend or not, map & 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
Q90. OOPS principles in Java
Ans.
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.
Add your answer
Q91. 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
Q92. 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
Q93. Tools that are used in java development.
Ans.
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
Add your answer
Q94. Java design principles
Ans.
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)
Add your answer
Q95. 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
Q96. Features of java. Basic concepts of java
Ans.
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)
View 1 answer
Q97. Spring is immutable or mutable
Ans.
Spring is immutable Spring framework is immutable Once a Spring bean is created, its state cannot be changed Any modifications to a Spring bean result in a new instance being created
Add your answer
Q98. 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 ...
read more
Add your answer
Q99. Java vs other language
Ans.
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 com...
read more
Add your answer
Q100. Drawback of java api stream
Ans.
One drawback of Java API Stream is that it can be less efficient for small collections. Stream operations can be slower for small collections compared to traditional loops. Stream operations can be harder to debug and understand for some developers. Stream operations can lead to increased memory usage due to intermediate objects created during processing.
Add your answer
1
2
3
Top Interview Questions for Related Skills
JavaScript Interview Questions and Answers
250 Questions
Python Interview Questions and Answers
200 Questions
C Interview Questions and Answers
150 Questions
C++ Interview Questions and Answers
150 Questions
C# Interview Questions and Answers
30 Questions
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories
Interview Questions of Java Related Designations
Software Developer Interview Questions and Answers
7.2k Questions
Software Engineer Interview Questions and Answers
6.8k Questions
Senior Software Engineer Interview Questions and Answers
3.7k Questions
Java Developer Interview Questions and Answers
1.8k Questions
System Engineer Interview Questions and Answers
1.6k Questions
Interview experiences of popular companies
3.7
• 9.8k Interviews
3.9
• 7.5k Interviews
3.7
• 7.2k Interviews
3.8
• 5.3k Interviews
3.7
• 5.1k Interviews
3.8
• 4.5k Interviews
3.6
• 3.6k Interviews
3.6
• 3.4k Interviews
4.1
• 2.3k Interviews
3.5
• 2.2k Interviews
Stay ahead in your career. Get AmbitionBox app
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