■ Java Interview Cheat Sheet (Fresher – Trainee
Role)
■ Core Java Basics
1. Java → Object-oriented, platform-independent (JVM).
2. JDK = Dev kit, JRE = Run env, JVM = Executes bytecode.
3. Access Modifiers → public, protected, default, private.
4. == compares references, .equals() compares content.
5. String (immutable), StringBuilder (mutable, fast), StringBuffer (mutable, thread-safe).
■ OOP Concepts
6. Four pillars: Encapsulation, Inheritance, Polymorphism, Abstraction.
7. Abstract class → abstract+concrete methods, Interface → only abstract (till Java7), supports
multiple inheritance.
8. Multiple inheritance → possible with interfaces.
9. Overloading → same name, diff params; Overriding → subclass redefines parent method.
10. Compile-time polymorphism = overloading, Runtime = overriding.
■ Collections Framework
11. ArrayList (fast access, slow insert/delete) vs LinkedList (slow access, fast insert/delete).
12. HashMap → O(1), no order; TreeMap → O(log n), sorted; LinkedHashMap → O(1), insertion
order.
13. HashMap uses hashing (hashcode → bucket).
14. HashSet → unordered, O(1); TreeSet → sorted, O(log n).
15. List → duplicates allowed; Set → unique; Map → key-value.
■ Exception Handling
16. throw → used to throw exception, throws → declares exception.
17. Checked → compile-time, Unchecked → runtime.
18. Multiple catch blocks → Yes.
19. finally → always executes, used for cleanup.
20. return in try & finally → finally overrides try.
■ Multithreading
21. Multithreading → running multiple tasks simultaneously.
22. Process = independent program, Thread = lightweight part of a process.
23. start() → creates new thread; run() → normal method call.
24. Create thread → extend Thread OR implement Runnable.
25. Synchronization → prevents data inconsistency in multithreading.
■ Coding Questions
26. Prime number check → loop from 2 to n/2.
27. Factorial → recursion or loop.
28. Reverse String → loop or [Link]().
29. Second largest → sort array, pick second last.
30. Palindrome → compare string with reverse.