Complete Summary of the Six‑Part Java Interview High‑Frequency Questions Series
This article compiles all 60 high‑frequency Java interview questions from six core backend topics—basics, collections, concurrency, JVM, Spring, and microservices—provides a quick‑reference table, outlines the most common and hardest questions, and shares a five‑layer answering technique for interview success.
Six‑Part Java Interview Summary
60 high‑frequency questions covering Basics, Collections, Concurrency, JVM, Spring, and Microservices.
Basics (10 questions)
Parameter passing – Java is pass‑by‑value.
String vs StringBuilder vs StringBuffer – mutability and thread‑safety.
== vs equals – reference vs value comparison.
hashCode and equals relationship – contract requirements.
final, finally, finalize – keyword semantics.
Interface vs abstract class – inheritance and implementation differences.
Four JVM reference types – strong, soft, weak, phantom.
Static vs non‑static inner classes – nesting and instance binding.
Generics and type erasure – compile‑time type safety, runtime type information loss.
Exception hierarchy – checked vs unchecked exceptions.
Collections (10 questions)
ArrayList vs LinkedList – array‑backed vs node‑based, random access vs insertion cost.
HashMap JDK 7 vs JDK 8 – bucket list vs tree bin after threshold.
HashMap put process – compute hash, locate bucket, handle collisions.
HashMap expansion – resize when load factor exceeds 0.75, rehashing.
ConcurrentHashMap principle – segment/striped locking (JDK 7) and CAS‑based bin splitting (JDK 8).
HashSet underlying structure – backed by HashMap with dummy value.
HashMap JDK 7 infinite loop issue – caused by concurrent resize without proper synchronization.
LinkedHashMap LRU – access‑order linked list for eviction.
Fail‑fast vs fail‑safe iteration – ConcurrentModificationException vs snapshot iterator.
Collection vs Collections – core interfaces vs utility class.
Concurrency (10 questions)
JMM – Java Memory Model defines visibility and ordering guarantees.
volatile principle – writes go to main memory, reads read from main memory, prevents reordering.
synchronized lock upgrade – from biased to lightweight to heavyweight lock via CAS on object header.
CAS and ABA problem – compare‑and‑swap can misinterpret reused values; solution via version stamp.
AQS core principle – CLH queue, state field, exclusive/shared modes.
ReentrantLock vs synchronized – explicit lock API, interruptibility, fairness options.
ThreadPoolExecutor seven parameters – corePoolSize, maximumPoolSize, keepAliveTime, workQueue, threadFactory, RejectedExecutionHandler, allowCoreThreadTimeOut.
ThreadLocal principle and memory leak – thread‑local map stored in Thread, potential leak if key is not removed.
CountDownLatch vs CyclicBarrier – one‑time vs reusable barrier synchronization.
Four conditions for deadlock – mutual exclusion, hold‑and‑wait, no preemption, circular wait.
JVM (10 questions)
JVM memory model – heap, metaspace, stack, PC registers, native method stacks.
Object allocation and lifecycle – new object in Eden, possible promotion to Survivor/Old.
GC algorithms – Serial, Parallel, CMS, G1, ZGC, Shenandoah.
GC collectors – young‑generation, old‑generation, mixed collectors.
Class loading mechanism – bootstrap, extension, application class loaders, delegation.
OOM troubleshooting – heap dump analysis, GC logs, -XX:+HeapDumpOnOutOfMemoryError.
CPU spike analysis – profiling, thread dump, JFR.
Memory leak investigation – heap dump, reference chains, tools like MAT.
JVM tuning parameters – -Xms, -Xmx, -XX:NewSize, -XX:MaxMetaspaceSize, GC flags.
Four reference types – strong, soft, weak, phantom.
Spring (10 questions)
IoC and DI – container creates and injects bean dependencies.
Bean lifecycle – instantiation, dependency injection, post‑processors, init‑method, destroy‑method.
AOP principle – proxy creation, method interception, pointcut expression.
Circular dependency resolution – three‑level cache (singletonFactories, earlySingletonObjects, singletonObjects).
@Transactional principle – proxy‑based transaction management, rollback rules.
Spring Boot startup process – bootstrap, auto‑configuration, component scanning.
Auto‑configuration principle – @ConditionalOnClass, @ConditionalOnMissingBean.
@Autowired vs @Resource – by type vs by name injection.
Bean scope – singleton, prototype, request, session, global session.
Filter vs Interceptor – servlet filter chain vs Spring MVC handler interceptor.
Microservices (10 questions)
Service registration and discovery – registry (e.g., Eureka, Consul) and client‑side lookup.
API gateway role – request routing, authentication, rate limiting, aggregation.
Fault tolerance – circuit breaker, fallback, rate limiting (e.g., Sentinel, Hystrix).
Distributed transaction solutions – two‑phase commit, saga, TCC.
Link tracing principle – trace ID propagation, span logs (e.g., Zipkin, Sleuth).
Configuration center purpose – centralized config management (e.g., Nacos, Apollo).
Message queue selection – reliability, ordering, throughput (Kafka, RabbitMQ, RocketMQ).
Idempotency design – deduplication keys, token, database unique constraint.
Distributed ID generation – Snowflake, UUID, database sequence.
Microservice splitting principles – bounded context, single responsibility, data ownership.
High‑Frequency Question Quick Reference
HashMap put process and expansion (Collections)
ConcurrentHashMap principle (Collections)
volatile and CAS (Concurrency)
synchronized lock upgrade (Concurrency)
Bean lifecycle (Spring)
AOP principle (Spring)
Spring Boot startup process (Spring)
JVM memory model (JVM)
Circular dependency resolution (Spring)
Service fault tolerance – circuit‑break, downgrade, rate‑limit (Microservices)
Top 5 Most Difficult Questions
AQS core principle – CLH queue, state, exclusive/shared modes.
synchronized lock upgrade – object header, Mark Word, CAS.
Spring circular dependency – three‑level cache.
ConcurrentHashMap principle – CAS + synchronized, expansion mechanism.
JVM tuning – requires real‑world experience.
Interview Answer Technique – Five‑Layer Method
What is it? One‑sentence definition. Example: “HashMap is a map implementation based on a hash table.”
How to use? Basic usage such as put, get, iteration.
Principle? Underlying implementation – array + linked list/red‑black tree, hash calculation.
Source code? Key code snippets – put flow, resize expansion.
Comparison? Contrast with similar concepts – e.g., compare with ConcurrentHashMap.
Suggestion: Start with layers 1‑2; dive deeper only if the interviewer probes further.
Handling Unknown Questions
1. Admit you don’t know but express willingness to learn
2. Mention related knowledge you do have
3. Ask the interviewer if you can approach the problem from another angle
4. Never fabricate an answerKeywords for Bonus Points
"I have read the source code" – demonstrates deep learning ability.
"I have encountered this in production" – demonstrates practical experience.
"Our solution was" – demonstrates problem‑solving capability.
"The essence of this problem is" – demonstrates abstract thinking.
"If I were to design it, I would" – demonstrates architectural design skill.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Coder Trainee
Experienced in Java and Python, we share and learn together. For submissions or collaborations, DM us.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
