Java Backend Interview Guide: Redis, Thread Pools, Spring, Concurrency, and Core Java Concepts

This article compiles a comprehensive Java backend interview guide covering Redis fundamentals, thread creation methods, thread‑pool pitfalls, Spring ecosystem relationships, IoC/AOP principles, shallow vs deep copying, collection cloning, differences between interfaces and abstract classes, and string handling classes, providing concise explanations and code examples for each topic.

IT Services Circle
IT Services Circle
IT Services Circle
Java Backend Interview Guide: Redis, Thread Pools, Spring, Concurrency, and Core Java Concepts

During the spring recruitment season, many candidates prepare for Java backend interviews by reviewing common interview questions and self‑testing. This guide collects a set of basic yet frequently asked questions that are easy to prepare for.

1. What is Redis and what does it do?

Redis (Remote Dictionary Server) is an open‑source, in‑memory NoSQL database written in C. It stores data in memory for extremely fast read/write operations and supports persistence. Redis provides various data structures such as String, Hash, Sorted Set, Bitmap, HyperLogLog, and GEO, as well as features like transactions, Lua scripting, and clustering (Sentinel, Cluster).

Key performance optimizations in Redis include:

Memory‑based storage, offering access speeds thousands of times faster than disk.

A Reactor‑style single‑threaded event loop with I/O multiplexing.

Optimized internal data structures for high performance.

Beyond caching, Redis can be used for distributed locks (often via Redisson), rate limiting (Redis + Lua), simple message queues (List) or advanced streams (similar to Kafka), delayed queues (Sorted Set), distributed sessions, and complex business scenarios like user activity statistics and leaderboards.

2. What data structures does Redis provide?

Redis offers five basic data types (String, List, Set, Hash, Zset) and three special types (HyperLogLog, Bitmap, Geospatial). Additional structures such as Bloom filters and Bitfields are also available.

3. Difference between synchronous and asynchronous calls

Synchronous : The caller blocks until a result is returned.

Asynchronous : The caller returns immediately without waiting for the result.

4. How to create a thread in Java?

Common ways include extending Thread, implementing Runnable or Callable, using thread pools, or using CompletableFuture. Ultimately, all of these rely on new Thread().start() to actually start a thread.

5. What is the purpose of a thread pool?

A thread pool manages a set of reusable threads, reducing the overhead of thread creation/destruction, improving response time, and providing better resource control. The Alibaba Java Development Manual recommends constructing thread pools directly via ThreadPoolExecutor instead of the Executors factory methods, which can lead to unbounded queues and potential OOM. FixedThreadPool and SingleThreadExecutor use an unbounded LinkedBlockingQueue (max size Integer.MAX_VALUE). CachedThreadPool uses a SynchronousQueue with potentially unlimited threads. ScheduledThreadPool and SingleThreadScheduledExecutor use an unbounded DelayedWorkQueue.

6. Relationship among Spring, Spring MVC, and Spring Boot

Spring provides core IoC functionality (Spring‑Core). Spring MVC builds on Spring to offer a Model‑View‑Controller web framework. Spring Boot simplifies Spring configuration, offering auto‑configuration and starter dependencies for rapid development.

7. IoC and AOP

IoC (Inversion of Control) delegates object creation and lifecycle management to the Spring container, improving modularity and testability.

AOP (Aspect‑Oriented Programming) separates cross‑cutting concerns (e.g., transactions, logging) from business logic. Spring AOP uses JDK dynamic proxies for interface‑based beans and CGLIB subclasses for concrete classes. AspectJ can also be integrated for more powerful weaving.

8. Shallow copy vs. deep copy

Shallow copy creates a new object but copies references for nested objects, so both copies share the same inner objects. Deep copy clones the entire object graph, producing independent nested objects.

Example of shallow copy using Cloneable:

public class Address implements Cloneable { private String name; /* getters/setters */ @Override public Address clone() { try { return (Address) super.clone(); } catch (CloneNotSupportedException e) { throw new AssertionError(); } }
public class Person implements Cloneable { private Address address; /* getters/setters */ @Override public Person clone() { try { Person p = (Person) super.clone(); return p; } catch (CloneNotSupportedException e) { throw new AssertionError(); } }

Testing shows that person1.clone() shares the same Address instance (shallow copy).

Deep copy modifies the clone() method to also clone the nested Address:

@Override public Person clone() { try { Person p = (Person) super.clone(); p.setAddress(address.clone()); return p; } catch (CloneNotSupportedException e) { throw new AssertionError(); } }

Now the cloned Person has an independent Address object.

9. List assignment a = b – shallow or deep copy?

Assigning one list to another is a reference copy; both variables point to the same list instance. To achieve a deep copy, create a new list and copy each element, cloning elements if they are mutable objects.

10. Differences between interfaces and abstract classes

Both cannot be instantiated directly and can contain abstract methods.

Both can provide default implementations (Java 8+ interfaces can have default methods).

Interfaces define contracts (behaviors) and allow multiple inheritance; abstract classes provide shared code and support single inheritance.

Interface fields are implicitly public static final; abstract class fields have normal visibility and can be overridden.

Abstract classes serve as a common template for subclasses, defining shared attributes and methods.

11. Differences among String, StringBuilder, and StringBuffer

String is immutable and therefore thread‑safe.

StringBuilder is mutable, non‑synchronized, and offers better performance in single‑threaded scenarios.

StringBuffer is mutable and synchronized, making it thread‑safe but slightly slower than StringBuilder.

Typical usage guidelines:

Small, infrequent modifications – use String.

Large, single‑threaded modifications – use StringBuilder.

Large, multi‑threaded modifications – use StringBuffer.

12. How does the backend pass data to the frontend?

RESTful APIs (HTTP GET/POST/PUT etc.)

WebSocket for full‑duplex real‑time communication

Server‑Sent Events (SSE) for one‑way server push

The choice depends on the application’s requirements for real‑time interaction and data volume.

References

[1] Redis – https://redis.io/

[2] Redis data types – https://redis.io/docs/data-types/

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.

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