Java Interview Guide

Ôn phỏng vấn Java backend theo kiểu hỏi – đápMỗi bài: vấn đề → giải pháp → vấn đề mới

1Java Core

  1. 1.1OOP & SOLID
  2. 1.2Interface vs abstract class
  3. 1.3String, immutability, String pool
  4. 1.4equals, hashCode, HashMap bên trong
  5. 1.5Collections: chọn cấu trúc nào
  6. 1.6List, Deque bên trong
  7. 1.7Map, Set, Heap bên trong
  8. 1.8Exception
  9. 1.9Generics
  10. 1.10Access modifier, static, final, pass-by-value
  11. 1.11Lambda & functional interface
  12. 1.12Stream API & các loại vòng lặp
  13. 1.13Optional, record, sealed
  14. 1.14Big-O & độ phức tạp
  15. 1.15Thuật toán sắp xếp
  16. 1.16Design patterns hay hỏi
  17. 1.17Design patterns trong Spring
  18. 1.18I/O, NIO, reflection

2JVM

  1. 2.1Java chạy thế nào: bytecode, JIT
  2. 2.2Stack vs Heap
  3. 2.3Class loading & module
  4. 2.4Garbage Collection
  5. 2.5Memory leak & OutOfMemoryError
  6. 2.6Chẩn đoán production: heap dump, thread dump, JFR

3Concurrency

Phần hay bị hỏi sâu nhất.

  1. 3.1Process vs Thread
  2. 3.2Tạo thread: Runnable vs Callable
  3. 3.3Thread pool & ExecutorService
  4. 3.4synchronized, volatile, atomic
  5. 3.5Race condition: hai request cùng sửa một dữ liệu
  6. 3.6Deadlock
  7. 3.7ReentrantLock & ReadWriteLock
  8. 3.8ThreadLocal
  9. 3.9CompletableFuture
  10. 3.10Concurrent collections
  11. 3.11Virtual threads
  12. 3.12Thread-safe từng method chưa đủ

4Spring

  1. 4.1Core & Boot
    1. 4.1.1IoC & Dependency Injection
    2. 4.1.2Bean scope & lifecycle
    3. 4.1.3AOP & proxy
    4. 4.1.4Auto-configuration & starters
    5. 4.1.5Profile & cấu hình
    6. 4.1.6Tự viết annotation
    7. 4.1.7Events, scheduling, @Async
    8. 4.1.8Spring Cache
    9. 4.1.9Actuator
    10. 4.1.10Debug Spring trên production
  2. 4.2Spring MVC
    1. 4.2.1Một request đi qua những đâu
    2. 4.2.2DispatcherServlet & HandlerMapping
    3. 4.2.3@Controller vs @RestController
    4. 4.2.4Nhận tham số
    5. 4.2.5HttpMessageConverter & Jackson
    6. 4.2.6Validation
    7. 4.2.7Exception handling
    8. 4.2.8Filter, Interceptor và AOP
    9. 4.2.9ResponseEntity, status code, header
    10. 4.2.10Upload & download file
    11. 4.2.11Gọi API khác: RestClient, WebClient
    12. 4.2.12Async trong MVC
    13. 4.2.13Test controller
  3. 4.3Spring Data JPA
    1. 4.3.1JPA, Hibernate, Spring Data
    2. 4.3.2Entity state & persistence context
    3. 4.3.3@Transactional và các bẫy
    4. 4.3.4Propagation & rollback
    5. 4.3.5Quan hệ entity
    6. 4.3.6N+1 query
    7. 4.3.7Lazy loading
    8. 4.3.8Query method, @Query, Specification
    9. 4.3.9Phân trang & sort
    10. 4.3.10Locking trong JPA
    11. 4.3.11Batch insert & hiệu năng
    12. 4.3.12Flyway & Liquibase
  4. 4.4Spring Security
    1. 4.4.1Filter chain
    2. 4.4.2Authentication flow
    3. 4.4.3Authorization
    4. 4.4.4Session-based login
    5. 4.4.5JWT
    6. 4.4.6Access & refresh token
    7. 4.4.7OAuth2 & OpenID Connect
    8. 4.4.8Resource Server & Keycloak
    9. 4.4.9Password, CORS, CSRF
    10. 4.4.10Method security & test
  5. 4.5Spring Reactive
    1. 4.5.1Vì sao cần reactive
    2. 4.5.2Event loop & non-blocking I/O
    3. 4.5.3Mono & Flux
    4. 4.5.4Operator hay dùng
    5. 4.5.5Lỗi, timeout, retry
    6. 4.5.6Backpressure
    7. 4.5.7Schedulers
    8. 4.5.8WebFlux & WebClient
    9. 4.5.9R2DBC
    10. 4.5.10MVC, WebFlux hay virtual threads
    11. 4.5.11StepVerifier
  6. 4.6Spring Cloud
    1. 4.6.1Từ monolith sang microservices
    2. 4.6.2Service discovery
    3. 4.6.3Config Server
    4. 4.6.4Spring Cloud Gateway
    5. 4.6.5OpenFeign & load balancer
    6. 4.6.6Resilience4j
    7. 4.6.7Spring Cloud Stream
    8. 4.6.8Distributed tracing
    9. 4.6.9Spring Cloud trên Kubernetes

5Testing

  1. 5.1Chiến lược test
  2. 5.2JUnit 5
  3. 5.3Mockito
  4. 5.4Spring test slices
  5. 5.5Testcontainers
  6. 5.6Test transaction & concurrency
  7. 5.7Messaging, contract, E2E
  8. 5.8Build & quality gate
  9. 5.9Flaky test

6Database (PostgreSQL)

  1. 6.1ACID & isolation level
  2. 6.2Kiến trúc PostgreSQL & WAL
  3. 6.3MVCC & VACUUM
  4. 6.4Index & EXPLAIN
  5. 6.5Lock & concurrent transaction
  6. 6.6Thiết kế schema & query
  7. 6.7Quan hệ bảng ↔ JPA
  8. 6.8Connection pool
  9. 6.9Replication, partition, sharding
  10. 6.10Backup & restore
  11. 6.11Full-text search với Elasticsearch/OpenSearch
  12. 6.12Vì sao Elasticsearch search nhanh: inverted index, Lucene
  13. 6.13Đồng bộ DB → search index

7Redis

  1. 7.1Kiến trúc & kiểu dữ liệu
  2. 7.2Chiến lược cache
  3. 7.3Persistence: RDB, AOF
  4. 7.4Replication, Sentinel, Cluster
  5. 7.5Distributed lock

8Messaging

  1. 8.1Vì sao cần message queue
  2. 8.2RabbitMQ: exchange & routing
  3. 8.3RabbitMQ: ACK & publisher confirm
  4. 8.4RabbitMQ: quorum queue
  5. 8.5RabbitMQ: retry, TTL, DLX
  6. 8.6Kafka: partitioned log
  7. 8.7Kafka: replication
  8. 8.8Kafka: consumer group & offset
  9. 8.9Kafka: delivery semantics & transaction
  10. 8.10RabbitMQ hay Kafka

9Networking & Web server

  1. 9.1Một request đi từ client tới Spring Boot
  2. 9.2IP, port, TCP và UDP
  3. 9.3Ping được nhưng không connect được: port & firewall
  4. 9.4DNS
  5. 9.5TLS/HTTPS
  6. 9.6HTTP: keep-alive, HTTP/2, caching
  7. 9.7Load balancer L4/L7, NAT, VPC
  8. 9.8Nginx reverse proxy
  9. 9.9Tomcat: connector & thread
  10. 9.10Timeout ở từng tầng
  11. 9.11Debug mạng: curl, dig, ss, tcpdump

10Linux: Process & Thread

  1. 10.1Process lifecycle
  2. 10.2Virtual memory
  3. 10.3Scheduler & context switch
  4. 10.4IPC, file descriptor, signal
  5. 10.5JVM thread ↔ OS thread
  6. 10.6Container & cgroups

11API Design & Security

  1. 11.1REST & resource contract
  2. 11.2PUT vs PATCH, status code
  3. 11.3Error contract & idempotency
  4. 11.4Versioning
  5. 11.5CORS, CSRF, XSS, CSP
  6. 11.6OWASP API Top 10
  7. 11.7Secrets & audit

12Keycloak

Identity Provider độc lập: quản lý user, đăng nhập, SSO. Phía Spring tích hợp xem bài 4.4.8.

  1. 12.1Keycloak là gì: realm, client, user, role
  2. 12.2Dựng Keycloak bằng Docker, export/import realm
  3. 12.3Các flow đăng nhập: Auth Code + PKCE, Client Credentials
  4. 12.4Role, group, mapper và nội dung token
  5. 12.5SSO, logout và session
  6. 12.6Keycloak trên production: HA, LDAP, admin API

13Cryptography

  1. 13.1Encoding, hash, encryption
  2. 13.2Hash & MAC
  3. 13.3Hash password
  4. 13.4Symmetric & AEAD
  5. 13.5RSA & chữ ký số
  6. 13.6PKI & quản lý key

14Distributed Systems

  1. 14.1Partial failure & clock
  2. 14.2Timeout, retry, deadline
  3. 14.3Circuit breaker, bulkhead
  4. 14.4Service boundary
  5. 14.5Consistency & CAP
  6. 14.6Saga
  7. 14.7Outbox, Inbox, CDC
  8. 14.8CQRS & Event Sourcing
  9. 14.9Order–Inventory–Payment end-to-end

15System Design

  1. 15.1Khung trả lời phỏng vấn
  2. 15.2Requirement, SLO, capacity
  3. 15.3Scale app, scale DB
  4. 15.4Rate limiting
  5. 15.5API Gateway
  6. 15.6High Availability
  7. 15.7URL Shortener
  8. 15.8File Upload
  9. 15.9Notification
  10. 15.10Ticket Booking
  11. 15.11Payment
  12. 15.12Flash sale
  13. 15.13Chat
  14. 15.14News Feed
  15. 15.15Banking transfer
  16. 15.16Multi-region

16Docker

  1. 16.1Image, layer, container
  2. 16.2Dockerfile
  3. 16.3Namespace & cgroups
  4. 16.4Volume & networking
  5. 16.5Compose
  6. 16.6PID 1 & signal
  7. 16.7Security

17Kubernetes

  1. 17.1Control plane
  2. 17.2Pod & probe
  3. 17.3Deployment, StatefulSet, Job
  4. 17.4Service & Ingress
  5. 17.5ConfigMap, Secret, RBAC
  6. 17.6Resource & autoscaling
  7. 17.7Troubleshooting
  8. 17.8Helm
  9. 17.9Giám sát Kubernetes: Prometheus stack & dashboard
  10. 17.10Log tập trung trên Kubernetes: Loki & Promtail
  11. 17.11ELK / OpenSearch trên Kubernetes

18Git, CI/CD & Cloud

  1. 18.1Git: merge, rebase, khôi phục
  2. 18.2CI pipeline
  3. 18.3CD & zero-downtime
  4. 18.4Terraform
  5. 18.5AWS
  6. 18.6Azure

19Observability

  1. 19.1Log, metric, trace
  2. 19.2SLI, SLO, alert
  3. 19.3Prometheus & Grafana
  4. 19.4OpenTelemetry
  5. 19.5Profiling & chẩn đoán JVM
  6. 19.6Xử lý incident & postmortem
  7. 19.7ELK Stack tổng quan, Elasticsearch vs OpenSearch
  8. 19.8Elasticsearch bên trong: index, shard, mapping
  9. 19.9Đưa log vào: Beats, Fluent Bit, Logstash, Kafka
  10. 19.10Kibana / OpenSearch Dashboards
  11. 19.11Vận hành ELK: ILM, sizing, snapshot, bảo mật
  12. 19.12Chọn ELK, Loki hay log của cloud

20Leadership & Behavioral

  1. 20.1Phạm vi của senior
  2. 20.2Estimate & ưu tiên
  3. 20.3ADR & code review
  4. 20.4Giao tiếp & mentoring
  5. 20.5Kể chuyện theo STAR

21AI Coding Workflow

  1. 21.1Làm việc với AI agent

Final Project: Ticket Booking

  1. 1Tổng quan & 12 milestone
  2. 2M0 · Requirements, capacity, dựng hạ tầng
  3. 3M1 · Chống bán trùng ghế
  4. 4M2 · Hold + expiry
  5. 5M3 · Thanh toán an toàn
  6. 6M4 · Lỗi dây chuyền A→B→C
  7. 7M5 · Saga + Outbox + Inbox
  8. 8M6 · Notification
  9. 9M7 · Flash sale
  10. 10M8 · Scale catalog
  11. 11M9 · Benchmark mô hình chạy
  12. 12M10 · Security + observability
  13. 13M11 · High availability
  14. 14M12 · Game day + mock interview

Phụ lục

  1. 1Câu hỏi phỏng vấn hay gặp
  2. 2Tự giới thiệu & kể về project