0% found this document useful (0 votes)
37 views26 pages

Java Interview Questions Answers

Uploaded by

Ayan goswami
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views26 pages

Java Interview Questions Answers

Uploaded by

Ayan goswami
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 26

Asked in

Java Developer Interview


Q1. OOPS Question
Which among String or String Buffer should be preferred when there are lot of
updates required to be done in the data?

View 2 more answers


right arrow

Java
Asked in
Java Developer Interview
Q2. write a code to filter out loans with incomplete status using java 8 features.
Ans. Code to filter out loans with incomplete status using Java 8 features.
Use stream() method to convert the list of loans into a stream

Use filter() method to filter out loans with incomplete status

Use collect() method to collect the filtered loans into a new list

View 4 more answers


right arrow

Software Development

Java
Infosys Java Developer Interview Questions and Answers for Freshers
View all interview questions
illustration image
Asked in
Java Developer Interview
Q3. 1.What is Singleton in java and create your own singleton class countering all
breakable conditions? 2. What is Auto Configuration? 3. @Primary vs @Qualifier 4.
What is idempotent? 5. What is class loader? Type...read more
Ans. The interview questions cover various topics related to Java development,
including Singleton pattern, memory management, exception handling, Spring
framework, and design patterns.
Singleton pattern ensures a class has only one instance and provides a global point
of access to it.

Auto Configuration in Spring Boot automatically configures the Spring application


based on dependencies present in the classpath.

@Primary annotation is used to give higher preference to a bean when mu...read more

Add your answer


right arrow
Asked in
Java Developer Interview
Q4. Spring Boot Question
What is the @Controller annotation used for? How can you create a controller
without an annotation?

Add your answer


right arrow

Spring Boot
Discover Infosys interview dos and don'ts from real experiences
View 7.5k interview experiences
Asked in
Java Developer Interview
Q5. SpringBoot Question
What is the starter dependency of the Spring boot module?

Add your answer


right arrow

Web Development

Spring Boot
Asked in
Java Developer Interview
Q6. OOPS Question
How would you differentiate between a String, StringBuffer, and a StringBuilder?

Add your answer


right arrow

Java
Are these interview questions helpful?

yes
Yes

no
No
Asked in
Java Developer Interview
Q7. Spring Boot Question
How to enable debugging log in the spring boot application?

Add your answer


right arrow

Web Development

Spring Boot
Asked in
Java Developer Interview
Q8. SpringBoot Question
What does the @SpringBootApplication annotation do internally?

Add your answer


right arrow

Java
Share interview questions and help millions of jobseekers 🌟

Share interview questions


man with laptop
Asked in
Java Developer Interview
Q9. MVC Question
What is the root application context in Spring MVC? How is it loaded?

Add your answer


right arrow
Spring MVC

Web Development
Asked in
Java Developer Interview
Q10. OOPS Question
What is meant by Interface?

Add your answer


right arrow
Asked in
Java Developer Interview
Q11. Difference Between Comparator and Comparable. What is fully qualified domain
name? What is the working principle for an ArrayList? How do you handle an
exception? What is custom exception? What is the differenc...read more
Ans. Comparator is used to compare objects for sorting, while Comparable is
implemented by objects to define their natural ordering.
Comparator is an external class, while Comparable is implemented by the object
itself.

Comparator can compare objects of different classes, while Comparable can only
compare objects of the same class.

Comparator uses the compare() method, while Comparable uses the compareTo() method.

View 1 answer
right arrow
Asked in
Java Developer Interview
Q12. OOPS Question
Explain the use of final keyword in variable, method and class.

Add your answer


right arrow

Java
Asked in
Java Developer Interview
Q13. Java Question
What's the difference between User thread and Daemon thread?

Add your answer


right arrow

Java

Multithreading
Asked in
Java Developer Interview
Q14. MVC Question
What are the different properties of MVC routes?

Add your answer


right arrow

Web Development

MVC
Asked in
Java Developer Interview
Q15. Java Question
What are some standard Java pre-defined functional interfaces?

Add your answer


right arrow

Java
Asked in
Java Developer Interview
Q16. OOPS Question
What is Garbage collector in JAVA?

Add your answer


right arrow

Java
Asked in
Java Developer Interview
Q17. Spring Boot Question
What is dependency Injection?

Add your answer


right arrow

Web Development

Spring Boot
Asked in
Java Developer Interview
Q18. Java Question
What are the features of a lambda expression?

Add your answer


right arrow

Java
Asked in
Java Developer Interview
Q19. Hibernate Question
Can you explain what is lazy loading in hibernate?

Add your answer


right arrow

Hibernate
Asked in
Java Developer Interview
Q20. Java Question
How ConcurrentHashMap works in Java

Add your answer


right arrow

Java
Asked in
Java Developer Interview
Q21. MVC Question
How is the routing carried out in MVC?
Add your answer
right arrow

Web Development

MVC
Asked in
Java Developer Interview
Q22. Hibernate Question
What is hibernate caching?

Add your answer


right arrow

Database Management

Hibernate
Asked in
Java Developer Interview
Q23. What is java and what is inheritance and what is oops concepts and what is
method
Ans. Java is an object-oriented programming language. Inheritance is a mechanism to
create new classes based on existing ones. OOPs is a programming paradigm. Method
is a block of code that performs a specific task.
Java is a high-level, class-based, and object-oriented programming language.

Inheritance is a mechanism in which one class acquires the properties and behaviors
of another class.

OOPs is a programming paradigm that focuses on objects and their interactions.

Method is a blo...read more

View 1 answer
right arrow

Java
Asked in
Java Developer Interview
Q24. Technical Question
What do you know about the Secure Socket Layer (SSL) ?

Add your answer


right arrow

Networking
Asked in
Java Developer Interview
Q25. Hibernate Question
When is merge() method of the hibernate session useful ?

Add your answer


right arrow

Hibernate
Asked in
Java Developer Interview
Q26. Spring Boot Question
What Are the Basic Annotations that Spring Boot Offers?

Add your answer


right arrow

Web Development

Spring Boot
Asked in
Java Developer Interview
Q27. What is polymorphism in both overloading and overriding way?
Ans. Polymorphism is the ability of an object to take on multiple forms. It can be
achieved through method overloading and overriding.
Method overloading is when multiple methods have the same name but different
parameters. The compiler decides which method to call based on the arguments
passed.

Method overriding is when a subclass provides its own implementation of a method


that is already present in its parent class. The method signature remains the same.

Polymorphism allows for co...read more

View 1 answer
right arrow
Asked in
Java Developer Interview
Q28. OOPS Question
Difference between Abstract class and Interface.

Add your answer


right arrow
Asked in
Java Developer Interview
Q29. Technical Question
How MVC works in Spring?

Add your answer


right arrow

Web Development
Asked in
Java Developer Interview
Q30. Technical Question
Explain in brief the role of different MVC components?

Add your answer


right arrow

Web Development
Asked in
Java Developer Interview
Q31. OOPS Question
How does an exception propagate in the code?

Add your answer


right arrow
Asked in
Java Developer Interview
Q32. Hibernate Question
How do you create an immutable class in hibernate?

Add your answer


right arrow

Database Management

Hibernate
Asked in
Java Developer Interview
Q33. Is java object oriented language or not ?
Ans. Yes, Java is an object-oriented language.
Java supports all the features of object-oriented programming such as
encapsulation, inheritance, and polymorphism.

All code in Java is written inside classes, which are objects.

Java also has interfaces, which allow for multiple inheritance.

Example: Java's String class is an object that has methods and properties.

Example: Inheritance in Java allows a subclass to inherit properties and methods


from a superclass.

View 2 more answers


right arrow

Java
Asked in
Java Developer Interview
Q34. Actuator,what is dependency injection, how to change imbeded server in spring
boot,W.A.P permutation of string
Ans. Answering questions related to Actuator, Dependency Injection, changing
embedded server in Spring Boot, and permutation of string.
Actuator is a Spring Boot feature that provides endpoints for monitoring and
managing the application.

Dependency Injection is a design pattern that allows objects to be created with


their dependencies injected from outside.

To change the embedded server in Spring Boot, you can exclude the default server
dependency and add a new one.

Permutation of st...read more

Add your answer


right arrow

Algorithms

Java

Spring Boot
Asked in
Java Developer Interview
Q35. DBMS Question
What is Self-Join and Cross-Join ?

Add your answer


right arrow

DBMS
Asked in
Java Developer Interview
Q36. Java Question
Difference b/w Runnable Interface and Callable Interface

Add your answer


right arrow

Java

Multithreading
Asked in
Java Developer Interview
Q37. Java Question
What is thread starvation?

Add your answer


right arrow

Java
Asked in
Java Developer Interview
Q38. Hibernate Question
Explain brief about Session interface used in hibernate?

Add your answer


right arrow

Hibernate
Asked in
Java Developer Interview
Q39. What is java and what is oops concepts and what is inheritance and what is
method
Ans. Java is an object-oriented programming language. OOPs concepts include
inheritance, encapsulation, polymorphism, and abstraction.
Java is a high-level programming language that is platform-independent.

OOPs concepts are the foundation of Java programming.

Inheritance is a mechanism in which one class acquires the properties and behaviors
of another class.

A method is a collection of statements that perform a specific task.

Examples of OOPs concepts in Java include encapsulation, p...read more

Add your answer


right arrow

Java
Asked in
Java Developer Interview
Q40. What is java and what is method and what is oops concepts and what is method
Ans. Java is an object-oriented programming language. Method is a block of code
that performs a specific task. OOPs concepts are principles of object-oriented
programming.
Java is a high-level programming language that is platform-independent.

Method is a block of code that performs a specific task and can be called multiple
times.

OOPs concepts include inheritance, encapsulation, polymorphism, and abstraction.

Inheritance allows a class to inherit properties and methods from another ...read
more

Add your answer


right arrow

Java
Asked in
Java Developer Interview
Q41. MVC Question
Difference b/w View and Partial View

Add your answer


right arrow

Web Development

MVC
Asked in
Java Developer Interview
Q42. Where should use for constructor injection?
Ans. Constructor injection should be used for mandatory dependencies.
Constructor injection is used to inject mandatory dependencies into a class.

It ensures that the class cannot be instantiated without the required dependencies.

It also makes the code more testable and maintainable.

Example: A Car class requires an Engine object to function. The Engine object is
injected via constructor injection.

Constructor injection is preferred over setter injection as it ensures that the


depende...read more

View 2 more answers


right arrow

Software Development

Design Patterns
Asked in
Java Developer Interview
Q43. What are aggregate and terminal operations in java8 streams
Ans. Aggregate operations perform operations on a stream of elements, while
terminal operations produce a result or side-effect.
Aggregate operations include map, filter, reduce, etc.

Terminal operations include forEach, collect, reduce, etc.

Example: stream.filter(x -> x > 5).map(x -> x * 2).forEach(System.out::println);

Add your answer


right arrow

Java
Asked in
Java Developer Interview
Q44. What is java and what is method and what is oops concepts
Ans. Java is a programming language. Method is a block of code that performs a
specific task. OOPs is a programming paradigm.
Java is an object-oriented programming language used to develop applications and
software.

A method is a block of code that performs a specific task and can be called by
other parts of the program.

OOPs is a programming paradigm that focuses on objects and their interactions to


solve problems.

OOPs concepts include encapsulation, inheritance, polymorphism, and ...read more

Add your answer


right arrow

Java
Asked in
Java Developer Interview
Q45. Can we use try and finally without catch?
Ans. Yes, try and finally can be used without catch to handle exceptions.
try block is used to enclose the code that may throw an exception

finally block is used to execute code regardless of whether an exception is thrown


or not

If catch block is not present, exceptions will not be caught and handled

Add your answer


right arrow

Java
Asked in
Java Developer Interview
Q46. Code in stream api - to find all the numbers less than 10 in a given array
list
Ans. Using stream api to find numbers less than 10 in an array list
Use stream() method on the array list to create a stream of elements

Use filter() method with a lambda expression to filter out numbers less than 10

Collect the filtered elements using collect() method to get the result

Add your answer


right arrow

Java

Data Structures
Asked in
Java Developer Interview
Q47. Java Question
Difference between save and saveorupdate
Add your answer
right arrow

Java

Hibernate
Asked in
Java Developer Interview
Q48. Java Question
Differentiate between .ear, .jar and .war files.

Add your answer


right arrow

Java
Asked in
Java Developer Interview
Q49. DBMS Question
Explain the concept of ACID properties in DBMS.

Add your answer


right arrow

DBMS
Asked in
Java Developer Interview
Q50. What would you rate yourself in java on the scale of 1 to 10?
Ans. I would rate myself as an 8 in Java.
I have extensive experience in Java programming and have successfully completed
multiple projects using Java.

I am familiar with various Java frameworks and libraries.

I have a strong understanding of object-oriented programming principles in Java.

I am comfortable working with Java's core features and APIs.

I continuously strive to improve my Java skills through self-learning and staying


updated with the latest developments in the Java ecosyst...read more

Add your answer


right arrow

Java
Asked in
Java Developer Interview
Q51. OS Question
Explain any 5 essential UNIX commands .

Add your answer


right arrow

Operating Systems
Asked in
Java Developer Interview
Q52. Explain project . How encapsulation and abstraction is used in your project
Ans. The project is a web application for managing inventory and sales of a retail
store.
Encapsulation is used to hide the internal implementation details of classes and
only expose necessary methods and properties.

Abstraction is used to define a common interface for interacting with different


types of inventory items, such as products and services.

For example, the Product class encapsulates details like name, price, and quantity,
while the InventoryManager class abstracts the ope...read more

Add your answer


right arrow

Encapsulation
Asked in
Java Developer Interview
Q53. String s1=new String(null); what is the answer
Ans. The code will throw a NullPointerException.
The code tries to create a new String object with a null value, which is not
allowed.

The constructor of String class does not accept null as a parameter.

The code will throw a NullPointerException at runtime.

Add your answer


right arrow

Java
Asked in
Java Developer Interview
Q54. Write a functional interface. Refer it to a Lamda Expression. Show it
practically while explaining each step
Ans. A functional interface is a single abstract method interface. It can be
referred to using a lambda expression.
Functional interfaces have only one abstract method

Lambda expressions can be used to implement functional interfaces

Lambda expressions provide a concise way to write anonymous functions

Functional interfaces can be used as method parameters or return types

Add your answer


right arrow

Java
Asked in
Java Developer Interview
Q55. What is HashMap? While Interating through it is it mutable?
Ans. HashMap is a data structure in Java that stores key-value pairs. It is mutable
while iterating through it.
HashMap is part of the Java Collections Framework.

It allows null values and at most one null key.

It provides constant-time performance for basic operations like get and put.

While iterating through a HashMap, it is mutable and can throw


ConcurrentModificationException if modified.
To avoid this, use an Iterator or ConcurrentHashMap.

Add your answer


right arrow

Algorithms

Data Structures
Asked in
Java Developer Interview
Q56. what is collection and collections, what is collection framework?
Ans. Collection is a group of objects, Collections is a utility class, Collection
framework is a set of interfaces and classes for handling collections.
Collection is an interface in Java that represents a group of objects known as
elements.

Collections is a utility class in Java that contains static methods for operating
on collections.

Collection framework is a set of interfaces and classes in Java that provides an


architecture to store and manipulate groups of objects.

Examples: Li...read more

Add your answer


right arrow

Data Structures

Collection Framework
Asked in
Java Developer Interview
Q57. What are the various annotations used in SpringBoot (explain)
Ans. Various annotations used in SpringBoot
1. @SpringBootApplication: Marks the main class of a Spring Boot application

2. @RestController: Marks a class as a RESTful controller

3. @RequestMapping: Maps HTTP requests to handler methods

4. @Autowired: Injects dependencies automatically

5. @Component: Marks a class as a Spring component

6. @Service: Marks a class as a service component

7. @Repository: Marks a class as a repository component

8. @Configuration: Marks a class as a source of b...read more

Add your answer


right arrow

Web Development
Asked in
Java Developer Interview
Q58. What are Java Generics, Collections, wrapper classes?
Ans. Java Generics are used to create classes, interfaces, and methods that operate
on objects of specified types. Collections are data structures to store and
manipulate groups of objects. Wrapper classes provide a way to use primitive data
types as objects.
Java Generics allow for type-safe operations on objects of specified types.
Example: List list = new ArrayList<>();

Collections provide data structures like List, Set, and Map to store and manipulate
groups of objects. Example:...read more

Add your answer


right arrow

Java
Asked in
Java Developer Interview
Q59. Explain Final,Finally,Finalize() in Java?
Ans. Final, Finally, Finalize() are keywords in Java used for different purposes.
Final is used to declare a variable as constant.

Finally is used to execute a block of code after try-catch block.

Finalize() is a method used for garbage collection.

Final can be used with classes, methods, and variables.

Finally block is always executed whether an exception is thrown or not.

Add your answer


right arrow

Java
Asked in
Java Developer Interview
Q60. what is the difference between string and stringbuffer, difference between
throw and throws
Ans. String is immutable while StringBuffer is mutable. throw is used to explicitly
throw an exception, throws is used in method signature to declare exceptions that
can be thrown.
String is immutable, meaning its value cannot be changed once it is created.
StringBuffer is mutable, meaning its value can be changed.

StringBuffer is synchronized, making it thread-safe. String is not synchronized.

throw keyword is used to explicitly throw an exception in a method. throws keyword


is used...read more

Add your answer


right arrow

Java
Asked in
Java Developer Interview
Q61. What is difference between Java and C, explain features of java
Ans. Java is a high-level programming language, while C is a low-level language.
Java is platform-independent and has automatic memory management.
Java is an object-oriented language, while C is a procedural language.

Java uses a virtual machine (JVM) for execution, while C directly compiles to
machine code.
Java has built-in garbage collection, while C requires manual memory management.

Java supports multithreading and exception handling, while C has limited support
for these feature...read more

Add your answer


right arrow

Java

C
Asked in
Java Developer Interview
Q62. OS Question
Explain Piping in Unix/Linux

Add your answer


right arrow

Operating Systems

Linux
Asked in
Java Developer Interview
Q63. 1.tell me about class loader in java and how it works? 2.Types of operators in
java. etc
Ans. Class loader in Java is responsible for loading classes into memory at
runtime. It follows a delegation hierarchy to find and load classes.
Class loader loads classes into memory dynamically at runtime

It follows a delegation hierarchy to find and load classes

Types of operators in Java include arithmetic, bitwise, logical, assignment, etc.

Add your answer


right arrow

Java
Asked in
Java Developer Interview
Q64. What is the jQuery ajax GET request syntax?
Ans. The jQuery ajax GET request syntax is used to send an HTTP GET request to a
server and retrieve data.
Use the $.ajax() method with the 'type' parameter set to 'GET'

Specify the URL of the server endpoint as the 'url' parameter

Handle the response using the 'success' callback function

Optionally, pass data to the server using the 'data' parameter

Add your answer


right arrow

jQuery

JavaScript
Web Development
Asked in
Java Developer Interview
Q65. Find the duplicate element in a given array using Java 8 features.
Ans. Find duplicate element in array using Java 8 features.
Convert array to stream using Arrays.stream()

Use Collectors.groupingBy() to group elements by their occurrence

Filter the grouped elements to find duplicates

Add your answer


right arrow

Java

Data Structures
Asked in
Java Developer Interview
Q66. What is Functional Interface? What is Flat Map? What is Method Reference? What
is stream API
Ans. Functional Interface is an interface with only one abstract method. Flat Map
is used to flatten nested collections. Method Reference is a shorthand notation for
lambda expressions. Stream API is used to process collections of objects.
Functional Interface is an interface with a single abstract method, such as
Runnable or Comparator.

Flat Map is a method in Java that is used to flatten nested collections, like List>
to List.

Method Reference is a shorthand notation for lambda exp...read more

Add your answer


right arrow

Java
Asked in
Java Developer Interview
Q67. have you worked on spring security then explain ?
Ans. Yes, I have worked on Spring Security. It is a powerful and customizable
authentication and access control framework for Java applications.
Implemented authentication and authorization using Spring Security annotations like
@Secured, @PreAuthorize, @PostAuthorize

Configured security settings in XML or Java configuration files

Used Spring Security filters for protecting URLs, CSRF protection, session
management, etc.

Integrated with various authentication providers like LDAP, OAut...read more

Add your answer


right arrow
Asked in
Java Developer Interview
Q68. Why java is not 100% object oriented? Explain in detail?
Ans. Java is not 100% object oriented because it supports primitive data types and
static methods.
Java supports primitive data types like int, float, and boolean which are not
objects.

Static methods in Java belong to the class itself and not to any specific object.

Java allows procedural programming constructs like static variables and methods.

Inheritance in Java is limited to single inheritance for classes, unlike pure


object-oriented languages like Smalltalk.

Add your answer


right arrow

Java
Asked in
Java Developer Interview
Q69. Prerequisites: Payment gateway If your order fails and payment has been
deducted, how do you manage this situation.
Ans. In case of order failure with payment deducted, refund the payment and
investigate the issue.
Initiate refund process for the deducted payment

Investigate the reason for the order failure

Communicate with the customer about the issue and resolution

Ensure the payment gateway is functioning correctly to prevent future occurrences

Add your answer


right arrow
Asked in
Java Developer Interview
Q70. What are @annotations in springboot? explain about @springBootApplication
Ans. Annotations in Spring Boot are used to provide metadata about the code.
@SpringBootApplication is a meta-annotation that combines @Configuration,
@EnableAutoConfiguration, and @ComponentScan.
Annotations in Spring Boot are used to simplify configuration and reduce
boilerplate code.

@SpringBootApplication is a meta-annotation that enables the auto-configuration


feature in Spring Boot.

It combines @Configuration, @EnableAutoConfiguration, and @ComponentScan


annotations.

Example: @S...read more

Add your answer


right arrow

Java

Spring Boot
Asked in
Java Developer Interview
Q71. Write code to put all the zeroes of an array to the end
Ans. Move all zeroes in an array to the end without changing the order of other
elements.
Iterate through the array and keep track of the index where non-zero elements
should be placed.
After the iteration, fill the remaining positions with zeroes.

Add your answer


right arrow

Algorithms
Asked in
Java Developer Interview
Q72. What are the different bean scopes in Spring
Ans. The different bean scopes in Spring are singleton, prototype, request,
session, and application.
Singleton scope creates a single instance of a bean per Spring IoC container.

Prototype scope creates a new instance of a bean every time it is requested.

Request scope creates a new instance of a bean for each HTTP request.

Session scope creates a new instance of a bean for each HTTP session.

Application scope creates a single instance of a bean per ServletContext.

Add your answer


right arrow

Spring
Asked in
Java Developer Interview
Q73. WAJP to establish a JDBC connection and fetch results from a database and
print those results.
Ans. Establish a JDBC connection and fetch results from a database using Java.
Import the necessary JDBC packages

Load and register the JDBC driver

Establish a connection to the database

Create a statement object

Execute a query to fetch results

Iterate over the result set and print the results

Close the result set, statement, and connection

Add your answer


right arrow

JDBC

SQL
Asked in
Java Developer Interview
Q74. What is static variables?
Ans. Static variables are variables that belong to the class itself, rather than an
instance of the class.
Static variables are declared using the 'static' keyword.

They are shared among all instances of the class.


They can be accessed without creating an object of the class.

Static variables are initialized only once, at the start of the program.

They are useful for storing data that is common to all instances of a class.

View 1 answer
right arrow
Asked in
Java Developer Interview
Q75. Coding: Sort list of student details using mark.
Ans. Sort list of student details by mark.
Create a custom class Student with attributes like name, mark.

Implement Comparator interface to sort by mark.

Use Collections.sort() method to sort the list of students.

Add your answer


right arrow
Asked in
Java Developer Interview
Q76. How can you write custom exception in Java?
Ans. To write a custom exception in Java, create a new class that extends Exception
or a subclass of Exception.
Create a new class that extends Exception or a subclass of Exception.

Add a constructor to the custom exception class to pass a message to the superclass
constructor.

Throw the custom exception using the 'throw' keyword in your code.

Handle the custom exception using try-catch blocks or propagate it up the call
stack.

Add your answer


right arrow

Software Development

Java
Asked in
Java Developer Interview
Q77. What is transient keyword in Java?
Ans. The transient keyword in Java is used to indicate that a variable should not
be serialized.
Variables marked as transient are not included in the serialization process

Transient variables are not saved when an object is serialized and are set to their
default values when the object is deserialized

Useful for excluding sensitive or unnecessary data from being serialized

Add your answer


right arrow

Java
Asked in
Java Developer Interview
Q78. What is agile?How it is used in your project?
Ans. Agile is a project management methodology that emphasizes flexibility,
collaboration, and iterative development.
Agile involves breaking down projects into small, manageable tasks called user
stories.

It promotes frequent communication and collaboration among team members.

Iterations, or sprints, are used to deliver working software incrementally.

Adaptability and responding to change are key principles of agile.

Examples of agile methodologies include Scrum, Kanban, and Extreme P...read more

Add your answer


right arrow

Agile
Asked in
Java Developer Interview
Q79. java code to explain exceptions using throws and throw
Ans. Using throws and throw in Java to handle exceptions
Use 'throws' to declare an exception in a method signature

Use 'throw' to manually throw an exception within a method

Example: public void divide(int a, int b) throws ArithmeticException { if(b == 0)


throw new ArithmeticException(); }

Add your answer


right arrow

Java
Asked in
Java Developer Interview
Q80. what is oops conecpts and give example?
Ans. OOPs concepts refer to Object-Oriented Programming principles like
inheritance, encapsulation, polymorphism, and abstraction.
Inheritance: Allows a class to inherit properties and behaviors from another class.
Example: class Dog extends Animal.

Encapsulation: Bundling data and methods that operate on the data into a single
unit. Example: private variables with public getter and setter methods.

Polymorphism: Ability to present the same interface for different data types.
Example:...read more

Add your answer


right arrow
Asked in
Java Developer Interview
Q81. 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


right arrow

Java
Asked in
Java Developer Interview
Q82. Write a program to find the missing element from the array.
Ans. Program to find missing element from array of strings
Iterate through the array and store elements in a HashSet

Iterate through another array and check if each element is present in the HashSet

Return the element that is not present in the HashSet

Add your answer


right arrow

Algorithms
Asked in
Java Developer Interview
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


right arrow

Java
Asked in
Java Developer Interview
Q84. What is String, collection, multithreading
Ans. String is a sequence of characters. Collection is a group of objects.
Multithreading is executing multiple threads simultaneously.
String is an immutable class in Java.

Collection is an interface that provides a way to store and manipulate groups of


objects.

Multithreading is used to improve the performance of an application by executing


multiple threads simultaneously.

Example of collection: ArrayList, LinkedList, HashSet, TreeSet.

Example of multithreading: creating and running ...read more


Add your answer
right arrow

Multithreading
Asked in
Java Developer Interview
Q85. How to manage during strict deadlines
Ans. Prioritize tasks, break down work into smaller chunks, communicate with team,
utilize time management techniques
Prioritize tasks based on importance and urgency

Break down work into smaller, manageable chunks to make progress

Communicate with team members to ensure everyone is on the same page

Utilize time management techniques such as Pomodoro technique or Agile


methodologies

Add your answer


right arrow
Asked in
Java Developer Interview
Q86. Can we run Java program without main
Ans. No, a Java program cannot be run without a main method.
The main method is the entry point of a Java program, without it the program cannot
be executed.

The JVM looks for the main method to start the execution of the program.

Attempting to run a Java program without a main method will result in a compilation
error.

Add your answer


right arrow

Java
Asked in
Java Developer Interview
Q87. Difference between list and set
Ans. List is an ordered collection that allows duplicate elements, while Set is an
unordered collection that does not allow duplicates.
List maintains the insertion order of elements, while Set does not guarantee any
specific order.

List allows duplicate elements, while Set does not allow duplicates.

Examples of List implementations in Java are ArrayList and LinkedList, while


examples of Set implementations are HashSet and TreeSet.

Add your answer


right arrow

Data Structures
Asked in
Java Developer Interview
Q88. Annotations in @springbootApplication
Ans. Annotations in @SpringBootApplication are used to configure the Spring Boot
application.
Annotations like @SpringBootApplication are used to enable auto-configuration and
component scanning in a Spring Boot application.

Other commonly used annotations include @RestController, @Service, @Repository, and


@Component for defining different types of Spring beans.

Annotations like @Autowired are used for dependency injection in Spring


applications.

Annotations like @RequestMapping are ...read more

Add your answer


right arrow

Java

Spring Boot
Asked in
Java Developer Interview
Q89. Is Java pass by value or by reference
Ans. Java is pass by value
Java is pass by value, meaning a copy of the variable is passed to a method

Changes made to the copy inside the method do not affect the original variable

However, if the variable is an object reference, the reference is passed by value

Add your answer


right arrow

Java
Asked in
Java Developer Interview
Q90. what is microservices ,how its works
Ans. Microservices are a software development technique where an application is
composed of small, independent services that communicate with each other.
Microservices break down a large application into smaller, loosely coupled services

Each service is responsible for a specific function and can be developed, deployed,
and scaled independently

Communication between services is typically done through APIs or messaging queues

Microservices architecture allows for better scalability, fl...read more

Add your answer


right arrow

Microservices
Asked in
Java Developer Interview
Q91. What is comparator annotation in Java?
Ans. Comparator annotation in Java is used to define custom sorting logic for
objects.
Comparator annotation is used to define custom sorting logic for objects in Java.

It is used in conjunction with the Comparator interface to provide custom sorting


behavior.
The annotation can be applied to fields or methods within a class to specify the
sorting order.

Example: @Comparator(order = Order.ASCENDING) private int age;

Add your answer


right arrow

Java
Asked in
Java Developer Interview
Q92. Features of java 8,oops,Custom Exception ,Collections
Ans. Java 8 introduced new features like lambda expressions and streams, OOPs
concepts include inheritance and polymorphism, custom exceptions allow for user-
defined exceptions, and collections provide data structures like lists and maps.
Java 8 features include lambda expressions and streams

OOPs concepts in Java include inheritance and polymorphism

Custom exceptions in Java allow for user-defined exceptions

Collections in Java provide data structures like lists and maps

Add your answer


right arrow

Java

Data Structures
Asked in
Java Developer Interview
Q93. what is serialization, deserialization, transient
Ans. Serialization is the process of converting an object into a byte stream,
deserialization is the reverse process. 'transient' keyword is used to exclude a
field from serialization.
Serialization is used to persist object state or transmit objects over a network

Deserialization is used to reconstruct the object from the byte stream

The 'transient' keyword in Java is used to indicate that a field should not be
serialized

Add your answer


right arrow
Asked in
Java Developer Interview
Q94. What is Method Overloading vs Overriding
Ans. Method Overloading is having multiple methods with the same name but different
parameters. Method Overriding is having a method in a subclass with the same name
and parameters as in the superclass.
Method Overloading is used to provide different ways of calling the same method
with different parameters.

Method Overriding is used to provide a specific implementation of a method that is


already provided by its superclass.

Method Overloading is resolved at compile-time based on the...read more

Add your answer


right arrow
Asked in
Java Developer Interview
Q95. Java collection use cases Hashmap working principle
Ans. Hashmap is a key-value pair data structure in Java used for fast retrieval of
data.
Hashmap stores data in key-value pairs

It uses hashing to store and retrieve data efficiently

Allows null keys and values

Example: HashMap map = new HashMap<>()

Add your answer


right arrow

Java

Data Structures
Asked in
Java Developer Interview
Q96. Write code to demonstrate the flow of Spring MVC
Ans. Demonstrate the flow of Spring MVC through code
Create a controller class with request mapping annotations

Define methods in the controller to handle different requests

Configure the dispatcher servlet in web.xml

Create a view resolver to map logical view names to actual views

Add your answer


right arrow

Spring MVC

Web Development
Asked in
Java Developer Interview
Q97. Difference btw string builder, and buffer
Ans. String Builder is not synchronized, while String Buffer is synchronized.
String Builder is faster than String Buffer because it is not synchronized.

String Buffer is thread-safe, while String Builder is not.

Use String Builder when you do not need thread safety, and String Buffer when you
do.

Add your answer


right arrow

Java
Asked in
Java Developer Interview
Q98. diffrenece between interafce and abstract class
Ans. Interface is a blueprint for classes to implement, while abstract class can
have both abstract and concrete methods.
Interface can only have abstract methods and constants, while abstract class can
have abstract and concrete methods.

A class can implement multiple interfaces but can only extend one abstract class.

Interfaces are used to achieve multiple inheritance in Java.

Abstract classes can have instance variables, constructors, and non-abstract


methods.

Example: interface Ani...read more

Add your answer


right arrow
Asked in
Java Developer Interview
Q99. What is JIT? Explain in Detail?
Ans. JIT stands for Just-In-Time compiler, which compiles Java bytecode into native
machine code at runtime for improved performance.
JIT compiler is a part of Java Virtual Machine (JVM) that helps in optimizing the
performance of Java applications by compiling bytecode into native machine code on-
the-fly.

It identifies frequently executed code and compiles it into native code for faster
execution.

JIT compilation occurs during the execution of the program, unlike ahead-of-time
compi...read more

Add your answer


right arrow
Asked in
Java Developer Interview
Q100. What are Stream terminal operators?
Ans. Stream terminal operators are used to trigger the execution of intermediate
operations in Java Streams.
Terminal operators return a result or a side effect, and the stream is consumed
after their execution.

Examples of terminal operators include forEach, collect, reduce, count, anyMatch,


allMatch, noneMatch, findFirst, findAny, etc.

You might also like