Java Backend Interview Guide: Networks, Data Structures, MySQL Logs, Elasticsearch, Kafka, Microservices, and Spring Essentials
This article compiles a comprehensive Java backend interview guide covering network protocols, HTTP characteristics, core data structures and algorithms, MySQL logging mechanisms, Elasticsearch full‑text search, Kafka reliability and deduplication, common micro‑service components, load‑balancing algorithms, and essential Spring concepts such as IoC, AOP, transactions, and MVC workflow.
Interview Topics Overview
The guide summarizes key interview questions for a Java backend position, emphasizing the need to master each technology stack rather than just superficial usage.
Network
DNS operates over UDP because it offers low latency, simplicity, and lightweight headers, with reliability handled by retries and caching.
HTTP characteristics: text‑based, extensible, flexible, and stateless, requiring mechanisms like cookies or sessions to maintain state.
Data Structures & Algorithms
Array vs. Linked List: access O(1) vs. O(n), insertion/deletion O(1) vs. O(n), cache locality, and appropriate use cases.
Implementing a queue with two stacks (stackPush and stackPop) – push to stackPush, pop/peek by transferring elements to stackPop when needed. The amortized complexity is O(1) for all operations.
import java.util.Stack;
class MyQueue {
private Stack<Integer> stackPush;
private Stack<Integer> stackPop;
public MyQueue() {
stackPush = new Stack<>();
stackPop = new Stack<>();
}
public void push(int x) { stackPush.push(x); }
public int pop() {
if (stackPop.isEmpty()) {
while (!stackPush.isEmpty()) {
stackPop.push(stackPush.pop());
}
}
return stackPop.pop();
}
public int peek() {
if (stackPop.isEmpty()) {
while (!stackPush.isEmpty()) {
stackPop.push(stackPush.pop());
}
}
return stackPop.peek();
}
public boolean empty() { return stackPush.isEmpty() && stackPop.isEmpty(); }
}
// Test code
public class Main {
public static void main(String[] args) {
MyQueue queue = new MyQueue();
queue.push(1);
queue.push(2);
System.out.println(queue.peek()); // 1
System.out.println(queue.pop()); // 1
System.out.println(queue.empty()); // false
}
}Backend Components
MySQL logs: redo log (transaction durability), binlog (replication & backup), undo log (rollback).
Elasticsearch full‑text search relies on inverted indexes that map terms to document IDs.
Kafka guarantees no data loss via producer acknowledgments, replicated partitions, and consumer offset management; it avoids duplicate consumption through idempotent producers, unique keys, or downstream deduplication (e.g., Redis or DB unique constraints).
Microservices
Common components: Eureka (service registry), Ribbon (client‑side load balancing), Feign (declarative HTTP client), Hystrix (circuit breaker), Zuul (API gateway), Config (configuration center).
Load‑balancing algorithms: simple round‑robin, weighted round‑robin, random, weighted random, consistent hashing, and least‑active.
Service circuit breaking and degradation concepts explained with Hystrix and fallback strategies.
Spring Essentials
IoC (Inversion of Control) – container creates, initializes, and destroys beans, decoupling object creation from business logic.
Why field injection is discouraged: external visibility, potential circular dependencies, and inability to inject final or static fields.
AOP fundamentals: aspects, join points, advice types, pointcuts, weaving, and proxy mechanisms (JDK dynamic proxy vs. CGLIB).
Transactional proxy behavior – self‑invocation via this bypasses the proxy, so transactions are not applied.
Spring resolves singleton setter‑based circular dependencies using a three‑level cache (singleton factories, early references, fully initialized beans).
Spring MVC request flow: DispatcherServlet → HandlerMapping → HandlerAdapter → Controller → ModelAndView → ViewResolver → View rendering → response.
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.
IT Services Circle
Delivering cutting-edge internet insights and practical learning resources. We're a passionate and principled IT media platform.
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.
