Java Developer

1500+ Java Developer Interview Questions and Answers

Updated 16 Dec 2024

Popular Companies

search-icon
Q51. OOPS Question

What is meant by Interface?

Q52. 6. Advantages and Disadvantages of immutable class?

Ans.

Immutable classes have advantages like thread safety, security, and simplicity, but also have disadvantages like memory usage and performance overhead.

  • Advantages of immutable classes:

  • - Thread safety: Immutable objects can be safely shared among multiple threads without the need for synchronization.

  • - Security: Immutable objects cannot be modified, which can prevent unauthorized changes to sensitive data.

  • - Simplicity: Immutable objects are easier to reason about and debug since...read more

Q53. Do you have any Java certficate? If no then please leave you are rejected.

Ans.

Java certification is not mandatory for a Java Developer role.

  • Certification is not a measure of practical skills and experience.

  • Experience and skills are more important than certification.

  • Certification can be helpful in some cases, but not mandatory.

  • Certification can be expensive and time-consuming.

  • Employers may value certification differently.

  • Examples of Java certifications: Oracle Certified Professional Java SE 11 Developer, Java SE 8 Programmer, etc.

Q54. Java Question

What are the primitive data types in Java?

Are these interview questions helpful?

Q55. 1.why we go with oops concept? 2.what is polymorphism? 3.what is JVM? 4.what is the Database connection coding in JAVA? 5.what is JOIN(QUERY)? 6.what is TRIGGER? 7.what is PROCEDURE? 8.what is Hashmap? 9.what i...

read more
Ans.

Basic Java and Query questions for Java Developer position.

  • OOPs concept helps in creating modular, reusable and maintainable code.

  • Polymorphism is the ability of an object to take on many forms.

  • JVM stands for Java Virtual Machine, which executes Java bytecode.

  • Database connection coding in Java involves creating a connection object, setting connection properties, and executing SQL queries.

  • JOIN is used to combine rows from two or more tables based on a related column between the...read more

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

Share interview questions and help millions of jobseekers 🌟

man-with-laptop

Q57. Where I implemented Executor service in my project?

Ans.

Implemented Executor service in the backend for parallel processing.

  • Implemented ExecutorService in the backend to handle multiple requests concurrently.

  • Used ExecutorService to execute multiple tasks in parallel.

  • Implemented ExecutorService to improve the performance of the application.

  • Used ExecutorService to manage thread pools and execute tasks asynchronously.

Q58. What is tha difference between object and object reference and object reference variable

Ans.

Object is an instance of a class while object reference is a variable that holds the memory address of the object.

  • Object is a real-world entity while object reference is a pointer to the memory location of the object.

  • Object reference variable is a variable that holds the reference of an object.

  • Object reference can be null while object cannot be null.

  • Multiple object references can refer to the same object.

  • Object reference can be reassigned to another object while object cannot...read more

Java Developer Jobs

Java Developer - 3-7 years 3-7 years
SAP India Pvt.Ltd
4.2
Bangalore / Bengaluru
Java Developer 3-5 years
IBM India Pvt. Limited
4.1
New Delhi
Java Developer 4-9 years
Verizon Data Services India Pvt.Ltd
4.2
Hyderabad / Secunderabad
Q59. Hibernate Question

Can you tell the difference between setMaxResults() and setFetchSize() of Query?

Q60. Java Question

What are collections in Java?

Q61. Java Question

What are some standard Java pre-defined functional interfaces?

Q62. Java Question

Why do we need to override equals and hashcode methods in Java?

Q63. Technical Question

What is Inversion of Control?

Q64. How to change a div background colour?

Ans.

To change a div background color in Java, use the setBackground() method and pass the desired color as a parameter.

  • Create a reference to the div element using its id or class

  • Use the setBackground() method to set the background color

  • Pass the desired color as a parameter to the setBackground() method

Q65. 1. How microservices communicate with each other?

Ans.

Microservices communicate with each other through APIs and messaging protocols.

  • Microservices use APIs to communicate with each other.

  • Messaging protocols like HTTP, AMQP, and MQTT are used for asynchronous communication.

  • Service discovery mechanisms like Eureka and Consul are used to locate services.

  • API gateways like Zuul and Kong are used to manage API traffic.

  • Event-driven architecture is used for real-time communication between services.

Q66. 13. Other than inheritance what you will use to connect two classes?

Ans.

We can use composition, aggregation, or association to connect two classes.

  • Composition is a strong form of aggregation where the lifetime of the contained object is controlled by the container object.

  • Aggregation is a weaker form of composition where the contained object has an independent lifecycle.

  • Association is a relationship between two classes where one class uses the functionality of another class.

  • Examples of association are dependency, inheritance, and realization.

  • Examp...read more

Q67. 9. When is memory allocated, when class is created or instance is created or when it is?

Ans.

Memory is allocated when an instance of a class is created.

  • Memory allocation happens when an object is created using the 'new' keyword.

  • Static variables are allocated memory when the class is loaded.

  • Memory is released when the object is no longer referenced or when the program terminates.

Q68. OOPS Question

Explain the use of final keyword in variable, method and class.

Q69. Spring Boot Question

What is Dependency Injection in Spring?

Q70. //design patterns //markers interface // example of functional interface . can you override Default method. Can you directly or do you need object. give some examples of functional interface //one try catch fin...

read more
Ans.

The interview questions cover a wide range of topics including design patterns, exception handling, Hibernate, MongoDB, Java collections, Spring framework, and microservices.

  • Design patterns like markers interface, functional interface, and Singleton pattern are important in Java development.

  • Understanding exception handling with try-catch-finally blocks is crucial for handling errors in Java applications.

  • Knowing the differences between load and get in Hibernate, as well as the...read more

Q71. What is the difference between Local Variable, static variable, and instance variable?

Ans.

Local, static, and instance variables differ in their scope and lifetime.

  • Local variables are declared inside a method and have a limited scope.

  • Static variables belong to the class and are shared among all instances.

  • Instance variables are unique to each object and can be accessed using the object reference.

Q72. Write a program for different types of books( Paperbook,E-book,Audiobook) using Inheritance Concept.

Ans.

Program for different types of books using Inheritance Concept

  • Create a Book class as the parent class

  • Create Paperbook, E-book, and Audiobook classes as child classes

  • Inherit properties and methods from the Book class

  • Add unique properties and methods to each child class

  • Example: Paperbook class can have a property for number of pages

  • Example: E-book class can have a property for file format

Q73. Java Question

What are the advantages of multithreading in Java?

Q74. Spring Boot Question

What is dependency Injection?

Q75. What is the difference between Hashmap and Hashtable?

Ans.

Hashtable is synchronized and does not allow null keys or values, while HashMap is not synchronized and allows null keys and values.

  • Hashtable is thread-safe, while HashMap is not.

  • Hashtable does not allow null keys or values, while HashMap allows null keys and values.

  • Hashtable is slower than HashMap due to synchronization.

  • Hashtable is a legacy class, while HashMap is part of the Java Collections Framework.

  • Hashtable is recommended to be used in multi-threaded environments, whil...read more

Q76. How do we call stored procedures in java ?

Ans.

Stored procedures can be called in Java using JDBC API.

  • Create a CallableStatement object using Connection.prepareCall() method.

  • Set the input parameters using setXXX() methods.

  • Execute the stored procedure using execute() or executeUpdate() method.

  • Retrieve the output parameters using getXXX() methods.

  • Close the CallableStatement object using close() method.

Q77. Java Question

What are the features of a lambda expression?

Q78. Java Question

What's the difference between User thread and Daemon thread?

Q79. MVC Question

What are the different properties of MVC routes?

Q80. 4. How to make a class immutable?

Ans.

To make a class immutable, we need to ensure that its state cannot be modified after creation.

  • Make all fields private and final

  • Do not provide any setters

  • Ensure that mutable objects are not returned from methods

  • Make the class final or use a private constructor

  • Consider using defensive copying

Q81. DBMS Question

What is the difference between MongoDB and MySQL?

Q82. Technical Question

What are the different states of Entity Instances?

Q83. What is daemon thread? How it help in multithreading?

Ans.

Daemon thread is a low priority thread that runs in the background and provides services to other threads.

  • Daemon threads are used for tasks that don't require user interaction or input.

  • They are automatically terminated when all non-daemon threads have completed.

  • Examples include garbage collection, logging, and monitoring.

  • They can be created using setDaemon() method.

  • Daemon threads should not be used for tasks that require data consistency or integrity.

  • They can help in improvin...read more

Q84. What is session in java?

Ans.

Session in Java is a way to store information about a user across multiple requests.

  • Session is used to maintain stateful information about a user.

  • It is created when a user first accesses a web application and remains active until the user logs out or the session times out.

  • Session data is stored on the server and can be accessed by multiple requests from the same user.

  • It is commonly used for user authentication, shopping carts, and personalization.

  • The HttpSession interface in ...read more

Q85. 1. Write a program to sort the characters of a string in descending order? 2. Write a lambda expression of addition? 3. How to write custom exceptions? 4. What is indexing?

Ans.

This program sorts the characters of a string in descending order.

  • Convert the string to a character array

  • Sort the character array in descending order

  • Convert the sorted character array back to a string

Q86. What are the internal partitions of the java virtual machine .

Ans.

Internal partitions of Java Virtual Machine

  • Java Virtual Machine has three internal partitions: Heap, Stack, and Method Area

  • Heap is used for dynamic memory allocation of objects and arrays

  • Stack is used for storing method frames and local variables

  • Method Area is used for storing class-level data such as method code and static variables

Q87. Hibernate Question

What are the concurrency strategies available in hibernate?

Q88. Microservices Question

What issues are generally solved by spring clouds?

Q89. Spring Boot Question

What does the @SpringBootApplication annotation do internally?

Q90. What are oops concepts, What are java8 features, functional interface, spring boot annotations, microservice.

Ans.

Answering questions related to OOPs concepts, Java8 features, functional interface, Spring Boot annotations, and microservices.

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

  • Java8 features include lambda expressions, streams, default methods, and functional interfaces.

  • Functional interface is an interface with only one abstract method and can be used with lambda expressions.

  • Spring Boot annotations include @RestController, @RequestMapping, @Auto...read more

Q91. what are the implicit objects in Jsp servlets ?

Ans.

Implicit objects in JSP servlets are pre-defined objects that can be accessed without any declaration.

  • Implicit objects are created by the container and are available to the JSP page.

  • Some of the implicit objects are request, response, session, application, out, pageContext, config, exception, etc.

  • These objects can be used to perform various operations like accessing request parameters, setting attributes, forwarding requests, etc.

Q92. OOPS Question

What is Garbage collector in JAVA?

Frequently asked in,

Q93. What is Exception and what is Exception Handling in java ?

Ans.

Exception is an event that occurs during the execution of a program and disrupts the normal flow of instructions.

  • Exception is a subclass of Throwable class.

  • Exception Handling is a mechanism to handle runtime errors and prevent program termination.

  • try-catch block is used to handle exceptions.

  • Multiple catch blocks can be used to handle different types of exceptions.

  • finally block is used to execute code after try-catch block.

  • Example: int a = 10/0; will throw ArithmeticException....read more

Q94. find sum of all odd numbers in a list using stream?

Ans.

Using Java stream, find the sum of all odd numbers in a list.

  • Use the filter() method to filter out the odd numbers from the list.

  • Use the mapToInt() method to convert the filtered numbers to integers.

  • Use the sum() method to calculate the sum of the filtered odd numbers.

Q95. Explain public static void main (String args []) in Java.

Ans.

Entry point for Java programs.

  • public: Access modifier that allows the method to be called from anywhere.

  • static: Method belongs to the class and not to any instance of the class.

  • void: Method does not return any value.

  • main: Method name that is recognized by JVM as the entry point for the program.

  • String args[]: Command line arguments passed to the program as an array of strings.

Q96. Hibernate Question

Can you explain what is lazy loading in hibernate?

Q97. Java 8 Question

Difference between Abstract Class and Interface in Java 8

Q98. Java Question

How ConcurrentHashMap works in Java

Q99. Java Question

What are the advantages of design patterns in Java ?

Q100. What is java? What is oops? Difference between hashmap and hashset

Ans.

Java is a high-level programming language known for its portability and object-oriented programming support. OOPs stands for Object-Oriented Programming. HashMap and HashSet are both data structures in Java, but HashMap is used to store key-value pairs while HashSet is used to store unique elements.

  • Java is a high-level programming language used for developing applications and software.

  • OOPs (Object-Oriented Programming) is a programming paradigm based on the concept of objects...read more

Previous
1
2
3
4
5
6
7
Next
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories

Interview experiences of popular companies

3.7
 • 10k Interviews
3.9
 • 7.8k Interviews
3.7
 • 7.3k Interviews
3.8
 • 5.4k Interviews
3.7
 • 5.2k Interviews
3.8
 • 4.6k Interviews
3.6
 • 3.7k Interviews
3.6
 • 3.6k Interviews
3.6
 • 2.3k Interviews
4.1
 • 2.3k Interviews
View all

Calculate your in-hand salary

Confused about how your in-hand salary is calculated? Enter your annual salary (CTC) and get your in-hand salary

Java Developer Interview Questions
Share an Interview
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions
Get AmbitionBox app

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

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