Fundamentals 12 min read

Comprehensive Java Interview Topics: Data Structures, Algorithms, JVM, Concurrency, Linux, Frameworks, Databases, Networking, Caching, and Design Patterns

This document compiles a wide range of Java interview questions covering data structures and algorithms, core Java concepts, JVM internals, multithreading, Linux usage, popular frameworks, database fundamentals, network protocols, caching systems, and common design patterns to help candidates prepare comprehensively.

Java Captain
Java Captain
Java Captain
Comprehensive Java Interview Topics: Data Structures, Algorithms, JVM, Concurrency, Linux, Frameworks, Databases, Networking, Caching, and Design Patterns

1. Data Structures & Algorithms Basics

Explain common sorting algorithms and their complexities.

Implement bubble sort in Java.

Describe linked storage structures.

How to traverse a binary tree?

Reverse a LinkedList.

Write a recursive Java method to traverse all files in a directory.

2. Java Fundamentals

Differences between interfaces and abstract classes.

Types of exceptions in Java and their usage.

Common collection classes and how to sort a List.

Implementation details of ArrayList and LinkedList, their pros and cons.

What causes memory overflow? Provide an example.

Difference between == and equals().

Purpose of hashCode() method.

What is NIO and its applicable scenarios?

How HashMap works and how to ensure its thread‑safety.

JVM memory layout and the need for garbage collection.

Differences between select and epoll, principles of I/O multiplexing.

Byte size of a Java character, and of int, long, double.

Ways to create an instance of a class.

Differences among final, finally, and finalize().

Session vs. Cookie.

Differences among String, StringBuffer, and StringBuilder, including their implementations.

Servlet lifecycle.

How to allocate a contiguous 1 GB memory block in Java and considerations.

Why memory leaks still occur despite Java's automatic garbage collection.

What is Java serialization and how to implement it (include a sample).

How many String objects are created by String s = new String("abc");?

3. JVM

Basic structure of the JVM heap.

Garbage collection algorithms and the CMS GC workflow.

Common JVM startup parameters and their descriptions.

How to monitor JVM memory usage.

Scenarios of memory overflow and memory leak with examples.

Frequently used JVM tuning parameters and their effects.

JVM memory architecture.

Typical GC strategies, when YGC and FGC are triggered.

4. Multithreading / Concurrency

How to create a thread and ensure thread safety.

Implementing a thread‑safe data structure.

Techniques to avoid deadlocks.

Purpose of the volatile keyword.

Precautions when using HashMap in a multithreaded environment.

Difference between calling run() and start() on a thread.

What are daemon threads and their use cases?

Definition of deadlock and avoidance strategies.

Differences between threads and processes.

Implementation of ThreadLocal in Java.

How ConcurrentHashMap works.

Differences between sleep and wait.

Differences between notify and notifyAll.

Role and implementation of ThreadLocal.

How to serialize execution of two threads.

Meaning of context switching.

Can a thread be killed at runtime?

Types of locks: condition lock, read/write lock, spin lock, re‑entrant lock.

Implementation principles of ThreadPoolExecutor.

5. Linux Usage & Troubleshooting

Two commands to create a file.

Differences between hard links and soft links.

Common Linux commands.

How to view resource consumption of a Java thread.

Possible causes of high load.

Purpose of /etc/hosts file.

Batch replace "abc" with "xyz" in a text file.

Search for error logs in a log file.

Identify the largest files when disk space is low.

Java server troubleshooting (OOM, high CPU, high load, class conflicts).

Common Java troubleshooting tools (top, iostat, vmstat, sar, tcpdump, jvisualvm, jmap, jconsole).

Analyzing thread dump files (runnable state, locks, stack, OS thread ID mapping).

How to view Java application thread information.

6. Framework Usage

Three states of a Hibernate entity.

Spring Bean lifecycle.

Request processing flow in Spring MVC or Struts.

Problems solved by Spring AOP and its implementation.

Transaction propagation attributes in Spring and their impact.

Difference between BeanFactory and FactoryBean.

Principles of IoC in Spring.

Various dependency injection methods in Spring.

Struts workflow.

Implementing an aspect in Spring.

How Spring handles database transactions.

Hibernate first‑ and second‑level cache usage and lazy loading.

How MyBatis performs batch commits.

7. Database Topics

Features of MySQL InnoDB and MyISAM.

Differences between optimistic and pessimistic locking.

Database isolation levels and their purpose.

Basic principle of MySQL master‑slave replication.

Execution order of

SELECT * FROM table t WHERE size > 10 GROUP BY size ORDER BY size

.

Performance optimization techniques (indexes, sharding, batch operations, pagination, SSD, business logic, master‑slave deployment).

When an SQL statement will not use an index (e.g., NOT IN, functions).

Typical fields suitable for indexing.

Query to select rows where name does not contain "XYZ".

MySQL B+ tree index implementation, row‑level locking, and SQL tuning.

Redis persistence models (RDB, AOF) and high‑availability/cluster solutions.

Solving high‑concurrency inventory reduction problems.

Mechanisms of index implementation in MySQL storage engines.

Granularity of database transactions.

Row lock vs. table lock; optimistic vs. pessimistic lock.

8. Network Protocols & Programming

TCP connection establishment process.

TCP connection termination process.

Logic behind HTTP 302 redirects.

HTTP interaction flow, differences between HTTP and HTTPS, SSL handshake.

Relationship between REST and HTTP; interpretation of RESTful style.

Purpose and principle of TCP sliding window.

HTTP methods.

Difference between switches and routers.

Basic flow of socket communication.

HTTP features (message structure, breakpoint resume, multi‑threaded download, keep‑alive).

TCP details (connection, slow start, sliding window, OSI layers).

WebService protocols (WSDL/SOAP) vs. REST.

Benefits of NIO, Netty threading model, and zero‑copy.

9. Caching, Middleware & NoSQL

Typical concurrency model of a Redis client.

How HBase implements fuzzy queries.

Common message middleware and how to guarantee ordering.

Designing a Hashtable, handling hash collisions, and optimization.

Distributed cache and consistent hashing.

LRU algorithm, slab allocation, reducing memory fragmentation.

Solving single‑node cache hotspot issues.

Bloom filter principle and meaning of false positives.

Differences between Memcached and Redis.

Functions of Zookeeper and its election algorithm.

Map/Reduce process and how to join two data sources using it.

10. Design Patterns & Refactoring

Examples of common design patterns.

Principles to follow when designing a factory package.

Open‑source projects using Visitor or Decorator patterns.

Frequently used design patterns in coding and their scenarios.

How to implement a Singleton (lazy, eager, double‑checked locking, volatile usage).

Proxy pattern (dynamic proxy).

Notable design pattern usages in JDK source code.

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.

Design PatternsJVMAlgorithms
Java Captain
Written by

Java Captain

Focused on Java technologies: SSM, the Spring ecosystem, microservices, MySQL, MyCat, clustering, distributed systems, middleware, Linux, networking, multithreading; occasionally covers DevOps tools like Jenkins, Nexus, Docker, ELK; shares practical tech insights and is dedicated to full‑stack Java development.

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.