Master Java Backend Interview Questions: HTTP Status, JVM, Multithreading & More

This article shares Beike's recent campus hiring salary data and provides a comprehensive Java backend interview guide covering HTTP response codes, session vs. cookie, runtime and checked exceptions, abstract classes vs. interfaces, StringBuilder vs. String, JVM memory structure, multithreading techniques, thread‑pool parameters, the synchronized keyword, B+‑tree indexing, and essential Linux commands.

Su San Talks Tech
Su San Talks Tech
Su San Talks Tech
Master Java Backend Interview Questions: HTTP Status, JVM, Multithreading & More

Hello, I am Su San. Many students ask if there are good mid‑size internet companies besides the big giants; Beike is a solid choice with competitive salaries and a tech stack comparable to top firms.

Below is the salary information for Beike's 25th campus recruitment for development positions (2022):

Bachelor Degree

Ordinary level: 20k–21k × 16 months = 320k–336k total package

Special (sp) level: 23k × 16 months = 368k total package

Master Degree

Ordinary level: 23k × 16 months = 368k total package

Special (sp) level: 25k × 16 months = 400k total package

Overall, the base salary starts at about 20k per month, which is close to the compensation of major internet companies.

Beike Java First‑Round Interview (Backend)

1. Common HTTP response codes?

HTTP status codes are divided into five categories:

1xx : Informational – rarely used.

2xx : Success – the server successfully processed the request.

3xx : Redirection – the client must request a new URL.

4xx : Client error – the request is malformed.

5xx : Server error – the server encountered an internal problem.

Typical codes include:

200 – OK

301 – Permanent redirect

302 – Temporary redirect

404 – Not found

405 – Method not allowed

500 – Internal server error

2. Difference between session and cookie?

Both are used to track user state, but they differ in storage location, capacity, security, lifecycle, and performance:

Storage : Cookie data resides on the client; Session data resides on the server and is identified by a Session ID.

Capacity : A cookie is limited to about 4KB; Session size is only limited by server memory.

Security : Cookies are vulnerable to XSS and CSRF; Sessions are generally safer but can be hijacked.

Lifecycle : Cookies can have an expiration time or be session‑only; Sessions expire after inactivity.

Performance : Cookies increase request payload; Sessions add server‑side lookup overhead.

3. Difference between runtime (unchecked) and non‑runtime (checked) exceptions?

Runtime exceptions arise from programming logic errors and are not forced to be handled at compile time, whereas checked exceptions represent foreseeable external problems and must be declared or caught.

Feature

RuntimeException

Checked Exception

Inheritance

extends RuntimeExceptionException directly extends Exception Compile‑time check

not required

must be caught or declared

Typical examples NullPointerException, IndexOutOfBoundsException,

ClassCastException
IOException

, SQLException, ClassNotFoundException The core distinction lies in whether the compiler enforces handling.

4. Difference between abstract class and interface?

Implementation: extends abstract class, implements interface. A class can extend only one abstract class but implement multiple interfaces.

Methods: Interfaces contain abstract methods (Java 8+ can have default/static methods); abstract classes can have concrete methods.

Fields: Interfaces can only have public static final constants; abstract classes can have instance fields with any access modifier.

5. Difference between StringBuffer and StringBuilder?

String is immutable; concatenation creates many temporary objects.

StringBuffer is thread‑safe, mutable, and uses synchronized methods.

StringBuilder (Java 5+) is like StringBuffer but without synchronization, offering better performance in single‑threaded scenarios.

Performance order (fastest to slowest): StringBuilder > StringBuffer > String.

6. When to use String vs. StringBuilder?

Use String when the content is immutable or only a few simple operations are needed; use StringBuilder for frequent modifications such as loops or dynamic generation. In multithreaded contexts, prefer StringBuffer.

7. JVM memory structure?

The JVM runtime memory consists of:

Program Counter : per‑thread pointer to the current bytecode instruction.

Java Virtual Machine Stack : stores frames for method calls, local variables, operand stack.

Native Method Stack : supports native (C/C++) method execution.

Java Heap : shared across threads; divided into young and old generations.

Method Area (Metaspace) : stores class metadata, static variables, and runtime constant pool.

Runtime Constant Pool : part of the method area, holds literals and symbolic references.

Direct Memory : off‑heap memory accessed via NIO for high‑performance I/O.

8. Ways to create a thread in Java?

Three primary approaches:

Extend Thread and override run(), then call start().

<code class="java">class MyThread extends Thread {
    @Override
    public void run() {
        for (int i = 0; i < 5; i++) {
            System.out.println("Thread " + Thread.currentThread().getId() + ": " + i);
            try { Thread.sleep(100); } catch (InterruptedException e) { e.printStackTrace(); }
        }
    }
}

public class ThreadExample {
    public static void main(String[] args) {
        MyThread t1 = new MyThread();
        MyThread t2 = new MyThread();
        t1.start();
        t2.start();
    }
}
</code>

Implement Runnable and pass an instance to a Thread.

<code class="java">class MyRunnable implements Runnable {
    @Override
    public void run() {
        for (int i = 0; i < 5; i++) {
            System.out.println("Runnable " + Thread.currentThread().getId() + ": " + i);
            try { Thread.sleep(100); } catch (InterruptedException e) { e.printStackTrace(); }
        }
    }
}

public class RunnableExample {
    public static void main(String[] args) {
        Thread t1 = new Thread(new MyRunnable());
        Thread t2 = new Thread(new MyRunnable());
        t1.start();
        t2.start();
    }
}
</code>

Implement Callable (Java 5+) to return a result and use FutureTask.

<code class="java">import java.util.concurrent.*;

class MyCallable implements Callable<Integer> {
    @Override
    public Integer call() throws Exception {
        int sum = 0;
        for (int i = 0; i <= 5; i++) {
            sum += i;
            System.out.println("Callable " + Thread.currentThread().getId() + ": " + i);
            Thread.sleep(100);
        }
        return sum;
    }
}

public class CallableExample {
    public static void main(String[] args) throws Exception {
        FutureTask<Integer> ft1 = new FutureTask<>(new MyCallable());
        FutureTask<Integer> ft2 = new FutureTask<>(new MyCallable());
        new Thread(ft1).start();
        new Thread(ft2).start();
        System.out.println("Result 1: " + ft1.get());
        System.out.println("Result 2: " + ft2.get());
    }
}
</code>

9. Common thread‑pool parameters?

corePoolSize : number of core threads kept alive.

maximumPoolSize : upper limit of threads.

keepAliveTime : time to keep excess idle threads before terminating.

unit : time unit for keepAliveTime.

workQueue : queue holding tasks awaiting execution.

threadFactory : creates new threads with custom settings.

handler : rejection policy when the queue is full and max threads are active.

10. How does the synchronized keyword work?

synchronized

acquires the object's monitor lock, ensuring exclusive access to the critical section. The lock state is stored in the object header’s Mark Word, which can transition among no‑lock, biased lock, lightweight lock, and heavyweight lock depending on contention. The JVM inserts monitorenter and monitorexit bytecode instructions to manage the lock.

11. Why does MySQL use B+‑tree indexes?

B+‑tree provides a high‑branching factor, reducing tree height and thus disk I/O. Non‑leaf nodes store only keys, maximizing fan‑out, while leaf nodes store full rows or pointers and are linked for efficient range scans. The structure is strictly balanced, guaranteeing consistent query performance.

12. Common Linux commands?

File operations: mv, mkdir, cd, ls Process monitoring: ps, top, netstat Permission management: chmod, chown, useradd, groupadd Network utilities: netstat, ip addr Testing connectivity: ping,

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

JavaJVMBackend DevelopmentLinuxmultithreadinginterview
Su San Talks Tech
Written by

Su San Talks Tech

Su San, former staff at several leading tech companies, is a top creator on Juejin and a premium creator on CSDN, and runs the free coding practice site www.susan.net.cn.

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.