Module: Java Interview Prep

Most Asked Questions

Core Java

  • Difference between == and equals()?
  • Why is String immutable?
  • How does Java achieve platform independence?
  • Explain JVM, JRE, and JDK.
  • What is hashCode() and its contract with equals()?
  • Difference between String, StringBuilder, and StringBuffer?
  • Why Java is pass-by-value?
  • final vs finally vs finalize()?
  • What are wrapper classes?
  • What happens internally when you run a Java program?

OOP Concepts

  • Explain OOP concepts.
  • Difference between abstraction and encapsulation.
  • Abstract class vs interface.
  • Why multiple inheritance is not supported in Java?
  • Method overloading vs method overriding.
  • Can we override static or private methods?
  • What is runtime polymorphism?
  • Composition vs inheritance.
  • What is loose coupling?
  • What are SOLID principles?

Exception Handling

  • Difference between checked and unchecked exceptions.
  • Can finally block be skipped?
  • throw vs throws.
  • What happens if exception occurs in finally block?
  • Can we create custom exceptions?

Collections Framework

  • Array vs ArrayList.
  • ArrayList vs LinkedList.
  • HashMap vs Hashtable.
  • How does HashMap work internally?
  • Why HashMap allows one null key?
  • HashMap vs ConcurrentHashMap.
  • What is fail-fast and fail-safe iterator?
  • Difference between Set, List, and Map.
  • Why is HashSet unordered?
  • How does HashSet work internally?

Multithreading

  • What is a thread?
  • How to create a thread in Java?
  • Thread vs Runnable.
  • What is synchronization?
  • What is deadlock?
  • How to avoid deadlock?
  • wait() vs sleep().
  • What is volatile keyword?
  • What is thread lifecycle?
  • What is Executor framework?

Java Memory & JVM

  • Difference between stack and heap memory.
  • What is garbage collection?
  • How does garbage collection work?
  • What is memory leak in Java?
  • What is ClassLoader?

Java 8 & Functional Programming

  • What is a Functional Interface?
  • Why Functional Interfaces are needed?
  • What is @FunctionalInterface annotation?
  • What is lambda expression?
  • Predicate vs Function vs Consumer vs Supplier.
  • What is Stream API?
  • map() vs flatMap().