0% found this document useful (0 votes)
8 views2 pages

Java Interview Cheatsheet

The document is a Java interview cheat sheet covering key concepts such as OOP principles, string handling, exceptions, collections, streams, concurrency, JVM, generics, I/O, modern Java features, serialization, performance, and security. It includes important notes on overloading, HashMap behavior, and resource management. The information is concise and structured for quick reference during interviews.

Uploaded by

techbuzz3934
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views2 pages

Java Interview Cheatsheet

The document is a Java interview cheat sheet covering key concepts such as OOP principles, string handling, exceptions, collections, streams, concurrency, JVM, generics, I/O, modern Java features, serialization, performance, and security. It includes important notes on overloading, HashMap behavior, and resource management. The information is concise and structured for quick reference during interviews.

Uploaded by

techbuzz3934
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Java Interview Cheat■Sheet

Last updated: August 13, 2025, 04:34 PM (IST)

1) OOP, Overloading & Overriding


Overloading: same name, different params. Preference: widening > boxing > varargs.
bullet
Overriding: cannot reduce visibility; covariant return allowed; checked exceptions can only narrow.
bullet
final cannot be overridden; static is hidden.
bullet

2) Strings & Secure Text Handling


String pool & intern(); immutable; StringBuilder vs StringBuffer.
bullet
Store secrets in char[]; avoid Strings/logging; wipe buffers after use.
bullet

3) Exceptions & TWR


Checked vs Unchecked; Errors unrecoverable.
bullet
TWR closes resources in reverse creation order; use getSuppressed().
bullet

4) Collections & Maps


Contracts: equals/hashCode/compareTo must align.
bullet
HashMap (JDK 8+): bins treeify at 8; untreeify at 6; min-tree-cap 64; load factor 0.75.
bullet
LinkedHashMap (order), TreeMap (sorted by key), HashSet uses HashMap.
bullet

5) Streams & Lambdas


Intermediate vs terminal ops; collectors (groupingBy, mapping, joining).
bullet
Parallel streams: CPU-bound only; avoid IO/shared mutability.
bullet

6) Concurrency & JMM


Happens-before via locks/volatile/join/start; volatile gives visibility not atomicity.
bullet
Atomics & LongAdder; ConcurrentHashMap has no segments since JDK 8.
bullet
Executors, CompletableFuture, virtual threads (Java 21).
bullet

7) JVM & GC
Young (Eden+S0/S1) → Old; Metaspace replaces PermGen.
bullet
GCs: G1 (default), ZGC, Shenandoah; System.gc() is only a hint; finalization deprecated.
bullet

8) Generics (PECS)
Invariance: List != List; type erasure; wildcards.
bullet
PECS: Producer extends, Consumer super.
bullet

9) I/O & NIO.2


Path/Files walk & WatchService; Channels & memory-mapped files; HttpClient.
bullet

10) Modern Java


Records, sealed types, pattern matching, text blocks, switch expressions, virtual threads.
bullet
11) Serialization & Externalization
Prefer JSON/Protobuf; serialVersionUID; transient; Externalizable for manual versioning.
bullet

12) Performance & Troubleshooting


p95/p99; JFR & async-profiler; JMH for microbenchmarks; minimize allocation & contention.
bullet

13) Security Basics


Keep secrets out of Strings/logs; KeyStore; ObjectInputFilter for deserialization.
bullet

Last■minute Gotchas
Overloading: widening > boxing > varargs; TWR closes in reverse.
bullet
HashMap: treeify=8, untreeify=6; CHM no segments; System.gc() is a hint.
bullet

You might also like