star iconstar iconstar iconstar iconstar icon

"Huge timesaver. Worth the money"

star iconstar iconstar iconstar iconstar icon

"It's an excellent tool"

star iconstar iconstar iconstar iconstar icon

"Fantastic catalogue of questions"

Ace your next tech interview with confidence

Explore our carefully curated catalog of interview essentials covering full-stack, data structures and algorithms, system design, data science, and machine learning interview questions

Java

100 Java interview questions

Only coding challenges
Topic progress: 0%

Java Basics & Language Components


  • 1.

    Explain the main idea behind Java and the concept of Write Once, Run Anywhere.

    Answer:
  • 2.

    What are the main features of Java?

    Answer:
  • 3.

    Can you list some non-object-oriented features of Java?

    Answer:
  • 4.

    Describe the difference between JDK, JRE, and JVM.

    Answer:
  • 5.

    What is the role of the ClassLoader?

    Answer:
  • 6.

    What is the difference between a path and a classpath in Java?

    Answer:
  • 7.

    Can you explain the difference between an int and an Integer in Java?

    Answer:
  • 8.

    What are wrapper classes in Java?

    Answer:
  • 9.

    What does it mean that Java is a statically typed language?

    Answer:
  • 10.

    Is Java a pure object-oriented language? Why or why not?

    Answer:
  • 11.

    What is bytecode in the context of Java?

    Answer:
  • 12.

    How does garbage collection work in Java?

    Answer:
  • 13.

    What is the purpose of the ‘final’ keyword?

    Answer:
  • 14.

    Can we overload or override static methods in Java?

    Answer:
  • 15.

    What is the significance of ‘this’ keyword in Java?

    Answer:

Object-Oriented Programming (OOP) Concepts


  • 16.

    Explain the four main principles of OOP.

    Lock icon indicating premium question
    Answer:
  • 17.

    How does Java implement inheritance?

    Lock icon indicating premium question
    Answer:
  • 18.

    What are interfaces, and how are they different from abstract classes?

    Lock icon indicating premium question
    Answer:
  • 19.

    Explain method overloading and method overriding.

    Lock icon indicating premium question
    Answer:
  • 20.

    What is polymorphism in Java? Give an example.

    Lock icon indicating premium question
    Answer:
  • 21.

    What is encapsulation in Java, and how is it achieved?

    Lock icon indicating premium question
    Answer:
  • 22.

    What is the Liskov Substitution Principle?

    Lock icon indicating premium question
    Answer:
  • 23.

    Can you illustrate the concept of coupling and cohesion in software design?

    Lock icon indicating premium question
    Answer:

Java Collections Framework


  • 24.

    Describe the Collections framework in Java.

    Lock icon indicating premium question
    Answer:
  • 25.

    What are the main differences between a List, Set, and Map in Java?

    Lock icon indicating premium question
    Answer:
  • 26.

    How does a HashSet work internally in Java?

    Lock icon indicating premium question
    Answer:
  • 27.

    Can you explain the difference between Comparable and Comparator interfaces?

    Lock icon indicating premium question
    Answer:
  • 28.

    What is the difference between HashMap and Hashtable?

    Lock icon indicating premium question
    Answer:
  • 29.

    What is the significance of equals() and hashCode() methods in Java?

    Lock icon indicating premium question
    Answer:
  • 30.

    What are the advantages of using Generics in collections?

    Lock icon indicating premium question
    Answer:
  • 31.

    How can we make a collection thread-safe in Java?

    Lock icon indicating premium question
    Answer:
  • 32.

    What are concurrent collections, and why do we use them?

    Lock icon indicating premium question
    Answer:

Exceptions and Error Handling


  • 33.

    What is the difference between an error and an exception in Java?

    Lock icon indicating premium question
    Answer:
  • 34.

    Can you explain Java’s exception hierarchy?

    Lock icon indicating premium question
    Answer:
  • 35.

    What is the difference between checked and unchecked exceptions?

    Lock icon indicating premium question
    Answer:
  • 36.

    How do you handle exceptions in Java?

    Lock icon indicating premium question
    Answer:
  • 37.

    What is a finally block, and when is it used?

    Lock icon indicating premium question
    Answer:
  • 38.

    Is it possible to catch multiple exceptions in a single catch block? If yes, how?

    Lock icon indicating premium question
    Answer:
  • 39.

    Can you throw any exception inside a lambda expression in Java?

    Lock icon indicating premium question
    Answer:

Java Concurrency


  • 40.

    What is the difference between a process and a thread in Java?

    Lock icon indicating premium question
    Answer:
  • 41.

    How do you create a thread in Java?

    Lock icon indicating premium question
    Answer:
  • 42.

    Explain the concept of synchronization in context with threads.

    Lock icon indicating premium question
    Answer:
  • 43.

    What is deadlocking in multithreading?

    Lock icon indicating premium question
    Answer:
  • 44.

    How can you avoid deadlocks?

    Lock icon indicating premium question
    Answer:
  • 45.

    Can you explain the working of the volatile keyword?

    Lock icon indicating premium question
    Answer:
  • 46.

    What is the difference between the synchronized method and synchronized block?

    Lock icon indicating premium question
    Answer:
  • 47.

    How does the ‘wait’ and ‘notify’ mechanism work in Java’s Object class?

    Lock icon indicating premium question
    Answer:
  • 48.

    What are Executors in Java concurrency?

    Lock icon indicating premium question
    Answer:

Java 8 and Newer Features


  • 49.

    Can you explain lambda expressions in Java 8?

    Lock icon indicating premium question
    Answer:
  • 50.

    How do default methods in interfaces work?

    Lock icon indicating premium question
    Answer:
  • 51.

    What is a stream in Java 8, and how is it different from a collection?

    Lock icon indicating premium question
    Answer:
  • 52.

    Explain the function of the Optional class in Java.

    Lock icon indicating premium question
    Answer:
  • 53.

    What are method references in Java 8?

    Lock icon indicating premium question
    Answer:
  • 54.

    How does the Java module system work?

    Lock icon indicating premium question
    Answer:
  • 55.

    What new features were introduced in Java 9, Java 10, Java 11, and beyond?

    Lock icon indicating premium question
    Answer:

Java Input/Output (I/O)


  • 56.

    Explain the Java I/O Streams model.

    Lock icon indicating premium question
    Answer:
  • 57.

    What is serialization in Java, and when would you use it?

    Lock icon indicating premium question
    Answer:
  • 58.

    What is the difference between File and Path in Java?

    Lock icon indicating premium question
    Answer:
  • 59.

    How do you read and write text files in Java?

    Lock icon indicating premium question
    Answer:
  • 60.

    What’s the difference between InputStream and Reader in Java?

    Lock icon indicating premium question
    Answer:

Networking in Java


  • 61.

    What is a socket in Java networking, and how do you create a simple client-server application?

    Lock icon indicating premium question
    Answer:
  • 62.

    What are the roles of the ServerSocket and Socket classes in Java?

    Lock icon indicating premium question
    Answer:
  • 63.

    Explain the HTTPURLConnection class.

    Lock icon indicating premium question
    Answer:

Java Memory Management


  • 64.

    How does the heap work in Java?

    Lock icon indicating premium question
    Answer:
  • 65.

    What are reference types in Java?

    Lock icon indicating premium question
    Answer:
  • 66.

    What is a memory leak and how would you prevent it in Java?

    Lock icon indicating premium question
    Answer:
  • 67.

    Explain the concept of “Escape Analysis” in Java.

    Lock icon indicating premium question
    Answer:

Java Annotations


  • 68.

    What are annotations in Java?

    Lock icon indicating premium question
    Answer:
  • 69.

    Can you create your own annotations?

    Lock icon indicating premium question
    Answer:
  • 70.

    What built-in annotations are provided by Java?

    Lock icon indicating premium question
    Answer:
  • 71.

    How are annotations used in frameworks such as Spring or Hibernate?

    Lock icon indicating premium question
    Answer:

Database Connectivity


  • 72.

    What is JDBC, and how do you connect to a database in Java?

    Lock icon indicating premium question
    Answer:
  • 73.

    Explain the role of the DriverManager class in JDBC.

    Lock icon indicating premium question
    Answer:
  • 74.

    How do you handle transactions in JDBC?

    Lock icon indicating premium question
    Answer:
  • 75.

    What is a PreparedStatement, and how does it prevent SQL injection?

    Lock icon indicating premium question
    Answer:

Testing in Java


  • 76.

    What is unit testing, and how is it implemented in Java?

    Lock icon indicating premium question
    Answer:
  • 77.

    Can you explain the difference between JUnit and TestNG?

    Lock icon indicating premium question
    Answer:
  • 78.

    What is mock testing, and which frameworks would you use for it in Java?

    Lock icon indicating premium question
    Answer:

Java Design Patterns


  • 79.

    What are design patterns, and why are they useful?

    Lock icon indicating premium question
    Answer:
  • 80.

    Can you explain the Singleton pattern and its pitfalls?

    Lock icon indicating premium question
    Answer:
  • 81.

    What is the Factory pattern in Java?

    Lock icon indicating premium question
    Answer:
  • 82.

    How does the Strategy pattern work?

    Lock icon indicating premium question
    Answer:
  • 83.

    What is the Observer pattern and where is it used?

    Lock icon indicating premium question
    Answer:

Java Security


  • 84.

    What is the Java security model?

    Lock icon indicating premium question
    Answer:
  • 85.

    How can you secure Java code against SQL injection attacks?

    Lock icon indicating premium question
    Answer:
  • 86.

    Explain the role of the SecurityManager in Java.

    Lock icon indicating premium question
    Answer:

Performance Tuning in Java


  • 87.

    How would you identify and improve the performance of a Java application?

    Lock icon indicating premium question
    Answer:
  • 88.

    What tools do you use for Java profiling?

    Lock icon indicating premium question
    Answer:
  • 89.

    What are some common performance issues in Java applications?

    Lock icon indicating premium question
    Answer:

Java Development Best Practices


  • 90.

    What are some coding best practices in Java?

    Lock icon indicating premium question
    Answer:
  • 91.

    How would you manage dependencies in a Java project?

    Lock icon indicating premium question
    Answer:
  • 92.

    What is continuous integration in the context of Java development?

    Lock icon indicating premium question
    Answer:

JVM Internals


  • 93.

    Explain the structure of the JVM and how it executes code.

    Lock icon indicating premium question
    Answer:
  • 94.

    How does the Just-In-Time (JIT) compiler work?

    Lock icon indicating premium question
    Answer:
  • 95.

    What is the role of the garbage collector in the JVM?

    Lock icon indicating premium question
    Answer:

Popular Java Frameworks


  • 96.

    What is Spring Framework and what problem does it solve?

    Lock icon indicating premium question
    Answer:
  • 97.

    How does Hibernate ORM work?

    Lock icon indicating premium question
    Answer:
  • 98.

    What is the purpose of the Spring Boot framework?

    Lock icon indicating premium question
    Answer:

Tools and Development Environments


  • 99.

    What IDEs are commonly used for Java development?

    Lock icon indicating premium question
    Answer:
  • 100.

    Are you familiar with build tools like Maven and Gradle?

    Lock icon indicating premium question
    Answer:
folder icon

Unlock interview insights

Get the inside track on what to expect in your next interview. Access a collection of high quality technical interview questions with detailed answers to help you prepare for your next coding interview.

graph icon

Track progress

Simple interface helps to track your learning progress. Easily navigate through the wide range of questions and focus on key topics you need for your interview success.

clock icon

Save time

Save countless hours searching for information on hundreds of low-quality sites designed to drive traffic and make money from advertising.

Land a six-figure job at one of the top tech companies

amazon logometa logogoogle logomicrosoft logoopenai logo
Ready to nail your next interview?

Stand out and get your dream job

scroll up button

Go up