Master Java Backend Interview: JVM, ClassLoaders, AOP, and More

This article guides job seekers through the autumn recruitment season, highlights bank hiring timelines and English requirements, and then provides a comprehensive Java interview Q&A covering JVM memory structures, object allocation failures, the parent‑delegation model, message‑queue usage, Spring AOP principles, and database string type differences.

IT Services Circle
IT Services Circle
IT Services Circle
Master Java Backend Interview: JVM, ClassLoaders, AOP, and More

As summer ends and September begins, the peak of autumn recruitment arrives; candidates are advised to submit resumes by mid‑September, especially for state‑owned enterprises and banks such as China Merchants Bank, which requires English proficiency (CET‑4 for undergraduates, CET‑6 for graduates).

The article then presents a detailed Java interview (Java 1st round) for the bank’s credit‑card center, covering essential topics.

China Merchants Bank (Java 1st Round)

1. What are the JVM memory structures?

According to the JDK 8 specification, the JVM runtime memory consists of the virtual machine stack, heap, metaspace (method area), program counter, and native method stack, plus direct memory.

Program Counter : a per‑thread pointer to the current bytecode line; null for native methods; the only area without an OutOfMemoryError condition.

Java Virtual Machine Stack : per‑thread stack storing local variables, operand stack, dynamic linking, and method exit information; can throw StackOverflowError or OutOfMemoryError.

Native Method Stack : similar to the JVM stack but serves native methods; may also throw StackOverflowError or OutOfMemoryError.

Java Heap : the largest shared memory area, divided into young and old generations; allocation failures raise OutOfMemoryError: Java heap space.

Method Area (Metaspace) : stores class metadata, constants, and static variables; uses native memory in JDK 8+.

Runtime Constant Pool : part of the method area holding literals and symbolic references; can cause OutOfMemoryError if memory is insufficient.

Direct Memory : off‑heap memory accessed via NIO, improves I/O performance but is limited by the host’s total memory.

2. When can adding an object to the heap fail?

Insufficient heap memory : if the remaining space cannot accommodate the new object and GC cannot free enough, the JVM throws OutOfMemoryError: Java heap space.

Heap allocation policy limits : parameters such as -Xmx, -XX:NewSize or -XX:MaxNewSize restrict the maximum heap size; if a new object exceeds the available space even after a full GC, allocation fails.

Large object allocation failure : some JVMs allocate very large objects directly to the old generation; if the old generation lacks sufficient space, the allocation fails.

Memory fragmentation : frequent allocation and reclamation may leave no contiguous block large enough for a big object, causing failure despite total free memory.

3. What is the parent‑delegation model?

The parent‑delegation model ensures that a class loader first delegates loading to its parent; only if the parent cannot load the class does the child attempt to load it.

Typical class loader hierarchy:

Bootstrap ClassLoader : loads core libraries from JAVA_HOME/lib (e.g., rt.jar).

Extension ClassLoader : loads extensions from JAVA_HOME/lib/ext.

Application ClassLoader : loads classes from the application classpath.

Custom ClassLoader : user‑defined loader extending ClassLoader for specific paths.

The model guarantees class uniqueness and protects core classes (e.g., java.lang.String) from being overridden, while allowing exceptions for SPI mechanisms and hot‑deployment scenarios.

4. In what scenarios are message queues used?

Decoupling : asynchronous communication between systems reduces tight coupling.

Asynchrony : long‑running operations (order creation, inventory update, customer tracking) can be processed later via MQ.

Peak‑shaving : MQ buffers bursts of traffic, allowing consumers to process at a sustainable rate.

5. How to ensure message delivery reliability?

Reliability spans three stages: producer, middleware, and consumer.

Producer stage : handle exceptions and retry until an acknowledgment (ack) from the MQ is received.

Storage stage : use replicated nodes (e.g., Kafka clusters) so that loss of a single node does not lose data.

Consumer stage : acknowledge only after successful processing; avoid premature ack to prevent loss.

6. How to guarantee idempotency in message consumption?

Generate a unique idempotency key (e.g., UUID) per request and check for prior processing.

Use database transactions with optimistic locking.

Enforce unique constraints in the database.

Apply distributed locks for high‑concurrency scenarios.

Perform message deduplication based on a unique message ID.

7. What is the principle behind Spring AOP?

Spring AOP relies on dynamic proxy technology, creating proxy objects at runtime to weave cross‑cutting concerns without modifying source code.

Two proxy mechanisms:

JDK dynamic proxy : uses java.lang.reflect.Proxy and java.lang.reflect.InvocationHandler; works when the target implements interfaces.

CGLIB proxy : generates a subclass of the target class when no interfaces are present.

8. Which annotations are used for AOP?

@Aspect

@Pointcut

@Before

@After

@Around

@AfterReturning

@AfterThrowing

@Advice

9. What are the differences between CHAR and VARCHAR?

CHAR : fixed‑length string, pads with spaces; efficient for short, fixed‑size data.

VARCHAR : variable‑length string, stores actual length; saves space for varying data.

10. What is the maximum capacity of VARCHAR?

A row can store up to 65 535 bytes, including overhead for length‑field and NULL‑bitmap. For a single VARCHAR(n) column with ASCII charset and allowing NULL, the maximum n is 65 532.

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.

JavaJVMclassloaderMessage Queueinterviewspring-aop
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.