Master Java Interview Essentials: OOP, Spring Beans, Redis, DB Indexes & More

This article compiles a comprehensive Java interview guide covering object‑oriented fundamentals, method overloading vs overriding, core collection implementations, Spring bean lifecycle, composite index usage, process/thread/coroutine distinctions, Linux IPC methods, design‑pattern principles, Redis roles and data types, relational vs NoSQL trade‑offs, QR‑code login design, and a classic 15‑minute brain teaser.

Java Tech Enthusiast
Java Tech Enthusiast
Java Tech Enthusiast
Master Java Interview Essentials: OOP, Spring Beans, Redis, DB Indexes & More

Alibaba Cainiao (Java Phone Interview)

1. Introduce Java object‑oriented features

Object‑oriented programming abstracts real‑world entities as objects with fields and methods. Java’s three OOP features are encapsulation, inheritance and polymorphism.

Encapsulation : combines data and behavior, hides internal details.

Inheritance : allows subclasses to reuse parent class structure.

Polymorphism : enables different classes to respond to the same message, including compile‑time (overloading) and runtime (overriding) polymorphism.

2. Difference between overloading and overriding

Overloading

defines multiple methods with the same name but different parameter lists in the same class. Overriding lets a subclass provide a new implementation for a method declared in its superclass, keeping the same signature.

3. Underlying data structures of ArrayList and HashSet

ArrayList

uses a dynamic array; HashSet is based on a hash table (HashMap).

ArrayList : dynamic array, initial capacity 10, expands by ~1.5×, allows duplicates, preserves insertion order.

HashSet : backed by a HashMap, stores elements as keys, disallows duplicates, unordered; in JDK 8+ long buckets become red‑black trees.

4. Bean lifecycle in Spring

Creation : instantiate bean and inject properties.

Initialization :

Invoke Aware interfaces.

Execute BeanPostProcessor before‑initialization.

Call InitializingBean.afterPropertiesSet or custom init‑method.

Execute BeanPostProcessor after‑initialization.

Usage : bean is ready for use in the container.

Destruction : call DisposableBean.destroy or custom destroy‑method when the container shuts down.

Bean lifecycle diagram
Bean lifecycle diagram

5. Which fields can use a composite index (a,b,c) in the query select * from table where a=? and b>? and c=? ?

The index can be used for a and b. Field c cannot be used for index lookup because b uses a range condition, but c can be filtered by index‑pushdown.

6. Differences among process, thread and coroutine

Process : OS resource‑allocation unit, independent memory space, heavy context switch.

Thread : CPU scheduling unit within a process, shares memory, lighter context switch, requires synchronization.

Coroutine : User‑level lightweight thread, scheduler controlled by the program, minimal switch cost, but requires explicit management.

7. Common IPC mechanisms in Linux

Pipe (anonymous and named)

Message queue

Shared memory

Semaphore

Signal

Socket (TCP, UDP, Unix domain)

8. Six principles of design patterns

Single Responsibility

Open/Closed

Liskov Substitution

Dependency Inversion

Interface Segregation

Law of Demeter

9. Typical uses of Redis

Cache

Leaderboard (sorted set)

Distributed lock

Counter

Message queue (pub/sub)

10. Redis data types

Core types: String, Hash, List, Set, Zset. Newer types (since later versions): BitMap, HyperLogLog, GEO, Stream.

Redis data types
Redis data types
Additional Redis data types
Additional Redis data types

11. Differences between relational databases and NoSQL

Relational databases store structured data in tables and support ACID guarantees. NoSQL databases store data as documents, key‑value pairs, hashes, etc., follow BASE principles, and provide easier horizontal scalability.

SQL vs NoSQL
SQL vs NoSQL

12. How to implement QR‑code login

Server generates a unique QR‑code ID, stores status “unscanned” in Redis, and displays the QR code.

User scans with a logged‑in mobile app, which sends the ID and its token to the server.

Server validates the token and marks the ID as “confirmed”.

Web client polls Redis, sees the confirmed status, and proceeds.

Server issues a session or token to the web client, completing login.

13. Brain teaser: measure 15 minutes with two incense sticks

Light one stick at both ends and the other at one end.

When the first stick burns out (30 min), light the opposite end of the second stick.

The remaining burn time of the second stick is now 15 minutes.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Design Patternsconcurrencyredisspringinterview
Java Tech Enthusiast
Written by

Java Tech Enthusiast

Sharing computer programming language knowledge, focusing on Java fundamentals, data structures, related tools, Spring Cloud, IntelliJ IDEA... Book giveaways, red‑packet rewards and other perks await!

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.