Java Developer Technical Interview – Detailed Answers
CORE JAVA
1. What is Java? Features:
- Platform Independent
- Object-Oriented
- Robust & Secure
- Multithreaded
- Portable
2. JDK vs JRE vs JVM
JDK = JRE + tools
JRE = JVM + libraries
JVM = runs bytecode
3. OOP Principles:
Encapsulation, Inheritance, Polymorphism, Abstraction
4. Abstract Class vs Interface:
Abstract: abstract + normal methods
Interface: only abstract (Java7), default/static (Java8)
5. Encapsulation:
Binding data + methods using getters/setters.
6. Polymorphism Types:
Compile-time (Overloading), Runtime (Overriding)
7. Overloading vs Overriding:
Overloading: same name, diff params.
Overriding: same name/params in subclass.
8. Constructor Types:
Default, Parameterized, Copy
9. String immutability reasons:
String pool, security, performance.
10. StringBuffer vs StringBuilder:
Buffer = synchronized, Builder = fast.
11. Collections:
List, Set, Map, Queue.
12. ArrayList vs LinkedList:
ArrayList = fast read
LinkedList = fast insert/delete
13. HashMap vs Hashtable:
HashMap allows null, faster.
14. Exception Handling:
try, catch, finally, throw, throws.
15. Checked vs Unchecked:
Checked = compile time.
Unchecked = runtime.
16. final, finally, finalize():
final = keyword
finally = always executes
finalize = GC method
17. Garbage Collection:
Automatic memory cleanup.
18. Thread Life Cycle:
New → Runnable → Running → Blocked → Terminated.
19. Synchronization:
One thread at a time.
20. Functional Interface:
One abstract method.
21. Lambda Expression:
() -> code
22. Stream API:
Used for filtering, mapping, sorting.
23. JVM Memory Areas:
Heap, Stack, Method Area.
CODING ANSWERS
1. Reverse String:
new StringBuilder(s).reverse()
2. Palindrome:
[Link](reverse)
3. Largest in Array:
loop + compare
4. Remove Duplicates:
new HashSet(list)
5. Fibonacci using loop
6. Count vowels using indexOf
7. Sum of digits using % and /
8. Character frequency using HashMap
9. Sort without built-in:
nested loops + swap
10. Missing number:
sum formula – array sum
SQL SECTION
1. PK = unique record
2. FK = references PK
3. 2nd highest salary query
4. Group by department count
5. Delete vs Truncate vs Drop differences