gitGood.dev

Java Interview Questions

Master Java concepts with questions on JVM internals, collections framework, multithreading, Spring Boot, and enterprise Java patterns.

35
Total Questions
13
Easy
17
Medium
5
Hard
Showing 1-20 of 35 questionsPage 1 of 2
Sign up to start practicing these questionsSign up free →
JVM Architecture
QuizMedium
JVM Memory Areas
QuizMedium
Garbage Collection Basics
QuizEasy
Generational Garbage Collection
QuizMedium
Pass by Value
QuizEasy
String Pool
QuizEasy
equals() and hashCode() Contract
QuizMedium
Autoboxing and Unboxing
QuizEasy
Abstract Class vs Interface
QuizEasy
Method Overloading vs Overriding
QuizEasy
The final Keyword
QuizEasy
Static Members
QuizEasy
Inner Class Types
QuizMedium
synchronized Keyword
QuizMedium
volatile Keyword
QuizMedium
Thread States
QuizMedium
ExecutorService
QuizMedium
CompletableFuture
QuizHard
Atomic Classes
QuizMedium
Deadlock Prevention
QuizHard

Frequently Asked Questions

What Java topics are most frequently tested?

Collections framework (HashMap, ArrayList, TreeMap), multithreading and concurrency (synchronized, ExecutorService), JVM internals (garbage collection, memory model), Stream API, generics, exception handling, and design patterns. For enterprise roles, Spring Boot, dependency injection, and microservices patterns.

Is Java still relevant for FAANG interviews?

Yes. Java is one of the most accepted languages for coding interviews at FAANG companies. Its strong typing, extensive standard library, and widespread use in enterprise backends make it a safe choice. Amazon, Google, and many others have large Java codebases.

How does the Java garbage collector work?

The JVM GC automatically manages memory using generational collection. Young Generation handles short-lived objects (Eden, Survivor spaces). Old Generation stores long-lived objects. Different collectors (G1, ZGC, Shenandoah) offer different latency and throughput trade-offs. Understanding GC tuning is important for performance-sensitive roles.

What is the difference between HashMap and ConcurrentHashMap?

HashMap is not thread-safe - concurrent access can cause data corruption. ConcurrentHashMap uses segment locking (Java 7) or CAS operations (Java 8+) for thread-safe access without blocking the entire map. Use ConcurrentHashMap in multi-threaded contexts and HashMap in single-threaded code.

What are Java Streams and when should I use them?

Streams provide a functional approach to processing collections with operations like filter, map, reduce, and collect. They support lazy evaluation and parallel processing. Use streams for data transformation pipelines. Avoid them for simple iterations or when performance is critical, as they add overhead.

How does dependency injection work in Spring?

Spring's IoC container manages object creation and wiring. You declare dependencies via @Autowired, constructor injection (preferred), or setter injection. Spring creates beans and injects them automatically. This promotes loose coupling, testability, and separation of concerns in enterprise applications.

Explore Other Categories