Backend Development 18 min read

What Makes Java Interviews Tough? A Deep Dive into Concurrency, JVM, MySQL, and More

This article analyzes 58.com’s recent business struggles and layoffs, then presents a comprehensive set of Java interview questions covering synchronized vs. Lock, JVM memory layout, garbage collection, TCP connection teardown, MySQL indexing pitfalls, and common sorting algorithms, providing detailed explanations and code examples.

IT Services Circle
IT Services Circle
IT Services Circle
What Makes Java Interviews Tough? A Deep Dive into Concurrency, JVM, MySQL, and More

58.com Business Overview

58.com has experienced continuous revenue decline, quarterly losses, and significant layoffs (20%‑30% of staff) as its core services shrink, while competitors such as BOSS直聘, 贝壳找房, 瓜子二手车, and algorithm‑driven platforms like 抖音 and 快手 erode its market share and user trust.

Java Interview Questions

synchronized vs Lock

Synchronized is a language keyword managed by the JVM, offering simpler syntax and automatic lock release on exceptions; Lock (e.g., ReentrantLock) is an interface providing richer features such as tryLock, interruptible lock acquisition, and explicit unlock, which can improve performance under high contention.

Lock is an interface, synchronized is a built‑in keyword.

Exceptions automatically release the synchronized lock, while Lock requires manual unlock to avoid deadlocks.

Lock supports interruptible waiting; synchronized does not.

Lock provides tryLock to check lock availability; synchronized does not.

Lock can improve read‑write concurrency via ReadWriteLock.

Under heavy contention, Lock outperforms synchronized.

public class SynchronizedReentrant {
    public synchronized void method1() {
        System.out.println("Method 1 called");
        method2(); // re‑entrant call
    }
    public synchronized void method2() {
        System.out.println("Method 2 called");
    }
}

ReentrantLock implements reentrancy using AQS state and exclusiveOwnerThread counters.

import java.util.concurrent.locks.ReentrantLock;
public class LockReentrant {
    private final ReentrantLock lock = new ReentrantLock();
    public void method1() {
        lock.lock();
        try {
            System.out.println("Method 1 called");
            method2(); // re‑entrant call
        } finally {
            lock.unlock();
        }
    }
    public void method2() {
        lock.lock();
        try {
            System.out.println("Method 2 called");
        } finally {
            lock.unlock();
        }
    }
}

JVM Object Storage

Objects created with

new

and arrays reside in the heap, which is shared among threads and managed by the garbage collector. Local variable references are stored on the thread stack; the method area (or metaspace in JDK 8+) holds class metadata, static variables, and the constant pool.

Object obj = new Object(); // heap
int[] arr = new int[10]; // heap
// reference stored on stack

New Generation vs Old Generation

New generation stores short‑lived objects; old generation stores long‑lived or large objects.

Memory proportion: ~1/3 new, ~2/3 old.

GC frequency: frequent minor GC in new generation, less frequent full GC in old generation.

Algorithms differ: copying algorithm for new generation, mark‑sweep/mark‑compact for old generation.

Different collectors are used (Serial, Parallel, CMS, G1, etc.).

Frequent Full GC Causes

Large objects directly allocated to old generation (‑XX:PretenureSizeThreshold).

Rapid promotion of young objects (‑XX:MaxTenuringThreshold).

Memory leaks via static collections, unclosed resources, or excessive object creation.

Metaspace/PermGen exhaustion.

Explicit

System.gc()

calls.

TIME_WAIT Overload

TIME_WAIT accumulates when many short‑lived connections are actively closed, often due to missing Keep‑Alive, load‑balancer misconfiguration, or server‑initiated closures.

Enable HTTP Keep‑Alive or connection pooling.

Let the client close connections (use

Connection: close

header appropriately).

Configure load balancers for persistent backend connections.

MySQL Composite Index Pitfalls

Not following left‑most prefix rule.

Applying functions or expressions to indexed columns.

Implicit type conversion mismatches.

Range query on the first column disables use of subsequent columns.

Leading wildcard in LIKE patterns.

OR conditions that don’t match the composite index.

Low selectivity indexes.

How MySQL Indexes Work

InnoDB uses B+Tree structures where leaf nodes store row pointers and internal nodes store index keys in sorted order, enabling logarithmic search with typically 3‑4 I/O operations for millions of rows.

SELECT * FROM product WHERE id = 5;

The B+Tree traverses root → intermediate → leaf to locate the row.

Common Sorting Algorithms

Bubble Sort – O(n²) time, O(1) space.

Insertion Sort – O(n²) time, O(1) space.

Selection Sort – O(n²) time, O(1) space.

Quick Sort – O(n log n) average, O(n²) worst, O(log n) space.

Merge Sort – O(n log n) time, O(n) space.

Heap Sort – O(n log n) time, O(1) space.

Additional Topics

Reverse words in a string (algorithm example).

Internship business content and tech stack overview.

Slow SQL optimization strategies.

JavaJVMconcurrencyMySQLInterviewNetworkingSorting
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

login 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.