Must‑Know Spring & Java Interview Questions from Xiaomi Car Hiring

The article first marvels at the record‑breaking sales of Xiaomi's YU7 electric SUV, then provides a comprehensive set of Java and Spring interview questions—including B‑tree differences, MySQL hash indexes, ReentrantLock internals, Spring's circular‑dependency resolution, AOP principles, and Spring Cloud components—to help candidates prepare for Xiaomi's upcoming campus recruitment.

IT Services Circle
IT Services Circle
IT Services Circle
Must‑Know Spring & Java Interview Questions from Xiaomi Car Hiring

Last week Xiaomi released the YU7 electric SUV, and the launch broke sales records: 200,000 units were pre‑ordered within three minutes, averaging about 1,111 units per second, and over 240,000 orders were placed in the first 18 hours, surpassing the combined six‑month sales of 25‑35 k RMB SUVs in China.

This unprecedented demand is likened to a miracle in the automotive industry and is expected to create many new job opportunities, especially for the upcoming campus recruitment for Xiaomi's automotive division.

To help candidates prepare, the following Java and Spring interview questions from last year's Xiaomi automotive campus hiring are shared.

Xiaomi Car (First Interview)

1. What is the difference between B+ tree and B tree?

In a B+ tree, all data is stored in leaf nodes, while non‑leaf nodes only contain index information; in a B tree, non‑leaf nodes also store some data.

B+ tree leaf nodes are linked together, which makes range queries and sequential access efficient; B tree leaf nodes are not linked.

Search performance of B+ tree is more stable because every search reaches a leaf node, whereas B tree may find data in internal nodes, leading to less predictable performance.

2. Do you know MySQL hash indexes?

MySQL hash indexes act as accelerators for specific scenarios, but they differ completely from the mainstream B+ tree indexes. InnoDB does not support manually creating hash indexes; only the Memory engine can use USING HASH to create them.

The principle is to compute a hash code for the key and map directly to a storage location. For equality queries such as user_id = 100 it can be faster than a B+ tree because it reaches the target in one step.

However, hash indexes have serious drawbacks: they destroy the natural order of data , making range queries impossible; they suffer from collisions , requiring chain traversal; and they require a full‑key match , so they cannot be used for partial indexes.

InnoDB provides an adaptive hash index (AHI) that automatically builds a hash index in memory for hot index pages, effectively adding a cache layer to the B+ tree for point queries.

In practice, use hash indexes only for in‑memory tables with equality lookups; for range queries or large data sets, stick with B+ tree indexes.

3. What situations cause an index to become ineffective?

Applying a function to an indexed column, e.g. YEAR(user_age), prevents the index from being used.

Performing arithmetic on an indexed column, e.g. price + 10, also disables the index.

Using LIKE '%pattern' with a leading wildcard makes the index unusable; LIKE 'pattern%' can still use the index.

Mismatched data types between the column and the query value, such as comparing an integer column with a string literal, may cause implicit conversion and index loss.

Combining conditions with OR where some columns lack indexes can force a full table scan.

-- Assume user_age column has an index
SELECT * FROM users WHERE YEAR(user_age) = 1990;
-- Assume price column has an index
SELECT * FROM products WHERE price + 10 < 100;
-- Assume username column has an index
SELECT * FROM users WHERE username LIKE '%test';
-- Assume user_id column is integer with an index
SELECT * FROM users WHERE user_id = '123';
SELECT * FROM users WHERE user_id = 1 OR user_name = 'test';

4. What is the principle of ReentrantLock?

ReentrantLock relies on the AQS (AbstractQueuedSynchronizer) framework, which maintains a state variable and a thread wait queue.

When a thread attempts to lock, it performs a CAS on state. If state is 0, the lock is acquired and state is incremented; otherwise the thread is enqueued and may spin or block.

The lock can be non‑fair (new threads may jump ahead) or fair (strict FIFO order).

Unlocking decrements state and wakes the next waiting thread, offering features such as timeout and interrupt support.

5. What is the role of the parent‑delegation model in the JVM and how can it be broken?

The parent‑delegation model serves three purposes: avoid duplicate class loading, protect core Java libraries, and ensure class uniqueness across class loaders.

It can be broken in scenarios such as SPI implementations, custom web‑container class loaders (e.g., Tomcat’s WebappClassLoader), or by using the thread‑context class loader to load classes that would otherwise be delegated to the parent.

6. How does Spring solve circular dependencies?

Spring resolves circular dependencies only for singleton beans injected via setter methods, using a three‑level cache:

Level 1: singletonObjects – fully initialized beans.

Level 2: earlySingletonObjects – early references exposed during property population.

Level 3: singletonFactoriesObjectFactory instances that can create the bean on demand.

The process includes bean instantiation, property population (exposing an early reference), initialization, and final dependency injection.

7. Why does Spring need a three‑level cache for circular dependencies?

Because beans that require AOP proxies must be fully initialized before the proxy is created; the third‑level cache stores an ObjectFactory that can produce either the raw bean or its proxy on demand, preserving singleton integrity and preventing duplicate instances.

8. What is the principle of AOP?

Spring AOP is based on dynamic proxy technology. It can use JDK interface‑based proxies or CGLIB subclass proxies to generate proxy objects at runtime without modifying the original source code.

9. Describe the two ways Spring creates dynamic proxies.

JDK dynamic proxy: Uses java.lang.reflect.Proxy and an InvocationHandler; the target class must implement at least one interface.

CGLIB proxy: Generates a subclass of the target class at runtime, allowing proxying of classes that do not implement any interfaces.

10. Can static proxies implement AOP?

Yes, static proxies can provide basic AOP‑like functionality, but they lead to code explosion, are brittle when interfaces change, and cannot select join points dynamically, so they are not used in production.

11. How are Spring beans destroyed?

During container shutdown, Spring destroys beans in order, invoking:

DisposableBean#destroy() if the bean implements DisposableBean.

Methods annotated with @PreDestroy (higher priority than custom destroy‑method).

Custom destroy methods defined in XML or via @Bean(destroyMethod=...).

Any DestructionAwareBeanPostProcessor callbacks.

The container also respects dependency relationships, destroying dependent beans before the beans they depend on.

12. What components make up Spring Cloud?

Service registry (e.g., Nacos).

Load balancing (Nacos load‑balancer, Ribbon).

Service communication (Feign, RestTemplate, Dubbo).

Configuration center (Nacos config).

Centralized logging (ELK, Alibaba LOG).

Distributed tracing (Sleuth/Zipkin).

Service protection (Sentinel).

Spring Cloud Alibaba integrates these components with Alibaba‑specific solutions such as Nacos for registration and configuration, Sentinel for circuit breaking, and Dubbo for RPC.

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.

Javaaopspringmysqlinterview
IT Services Circle
Written by

IT Services Circle

Delivering cutting-edge internet insights and practical learning resources. We're a passionate and principled IT media platform.

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.