Add interview module: 30 design pattern interview questions with tests (Java 25, Spring 7.0.10)

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017ic4b7rnC7jppGGdHGESvy
This commit is contained in:
Claude
2026-10-28 18:10:09 +00:00
parent f5688a6b32
commit c51641b7db
48 changed files with 1617 additions and 1 deletions
+13
View File
@@ -0,0 +1,13 @@
Q1 eager: getInstance() == getInstance() -> true
Q2 naive lazy, 8 threads: distinct instances=more than 1 constructor runs=8
Q3 synchronized, 8 threads: distinct instances=1 constructor runs=1
Q4 DCL with volatile, 8 threads: distinct instances=1 constructor runs=1
Q4 DclSingleton.instance volatile? true
Q4 DclWithoutVolatile.instance volatile? false
Q5 holder before first getInstance(): constructor runs=0
Q5 holder after two getInstance() calls: constructor runs=1 same=true
Q6 serialisation round trip keeps the same instance? classic=false hardened(readResolve)=true enum=true
Q6 reflection newInstance() on classic private constructor returns the singleton? false
Q6 reflection on hardened constructor: InvocationTargetException caused by java.lang.IllegalStateException: already initialised
Q6 reflection on enum constructor: java.lang.IllegalArgumentException: Cannot reflectively create enum objects
Q7 Spring singleton scope: same bean twice from one context? true; same bean across two contexts? false