1. What is the difference between Fail-Fast and Fail-Safe Iterators in Java Collections?
Describe how they detect concurrent modifications and give examples of collections implementing each
behavior.
2. Explain the use of AtomicInteger in synchronized multi-threading scenarios.
What problems does it solve compared to using synchronized blocks?
3. How can an Employee class be safely used as a key in a HashMap?
Mention the importance of overriding equals() and hashCode() methods, and how immutability plays a role.
4. How would you design an immutable Student class in Java?
Describe best practices like final fields, constructor initialization, no setters, and defensive copying of mutable
fields.
5. What is the internal working behavior of TreeSet in Java?
Explain how it maintains elements in sorted order and uses Red-Black Tree internally.
6. What is the purpose of the Java Collections Framework?
Discuss its architecture, standard interfaces, algorithms, and why it is important for developers.
7. How do you resolve constructor chaining issues in Java inheritance?
Explain using super() to call parent constructors and how to handle absence of default constructors.
8. What issues arise if mutable objects are inserted into a HashSet?
Analyze how changes in object properties can corrupt the internal structure and impact lookup.
9. How to convert a List<Student> into a Map<Integer, String> using Java Streams?
Explain key collisions handling and how LinkedHashMap preserves insertion order.
10. How does deadlock occur in multi-threaded programs?
Illustrate with an example and describe how to avoid it by using consistent locking orders.
11. How do you remove duplicates from a sorted array in-place?
Describe two pointer approach and space/time complexities.
12. How do you find the length of the longest consecutive sequence in an array?
Explain using HashSet for O(n) solution without sorting.
13. How to find the second largest element in an array?
Demonstrate how to do it in a single scan efficiently.
14. How do you split an array into chunks in Java?
Outline array slicing logic in a loop with a given chunk size.
15. How do you find the first missing positive integer in an unsorted array?
Describe bucket placement and swapping techniques to solve in O(n) time.
16. How would you group anagrams together in Java?
Explain how sorting or character counting can help group anagrams efficiently.
17. How do you validate a Sudoku board?
List checks for rows, columns, and 3x3 boxes ensuring no duplicates.
18. How do you perform a spiral traversal of a matrix?
Discuss handling boundaries and edge cases for rectangular matrices.
19. How would you print numbers sequentially using three threads?
Propose using Semaphores or ReentrantLock and Conditions for controlling thread execution order.
20. What is String Pool in Java and how does it optimize memory?
Explain interned strings, memory sharing, and immutability importance.
21. Write an SQL query to assign grades based on student marks.
Explain join logic and how ranges are handled using BETWEEN operator.
22. How to calculate highest total marks considering multiple attempts in SQL?
Describe use of aggregation, GROUP BY, and subqueries.
23. How do you classify a triangle using SQL based on side lengths?
Explain conditions for Equilateral, Isosceles, Scalene, and invalid triangles.
24. How to sort students by Grade and Marks using SQL?
Show ORDER BY clause usage for multi-level sorting.
25. How would you design a deck of cards using OOP principles?
Discuss Suit, Rank enums, Card class, and Deck operations like shuffle and sort.
26. What are the differences between ArrayList, LinkedList, HashSet, and TreeSet?
Compare their data structures, performance for insert/search, and ordering guarantees.
27. Why use ConcurrentHashMap over HashMap in multithreaded environments?
Explain segment locking and better concurrency behavior.
28. How can you handle duplicates while converting List to Map using Streams?
Describe merge functions and how to prioritize latest values.
29. Explain the internal working of HashMap in Java.
Describe how hashing, buckets, and collision resolution using linked list/tree works.
30. How does TreeMap ensure natural ordering of keys?
Explain Red-Black Tree properties and comparator logic.
31. What are best practices for audio/video behavior assessment during interviews?
Explain how candidates are evaluated for genuine and independent participation.
32. How to assess debugging skills during a technical interview?
Outline signs like systematic tracing, meaningful logging, and hypothesis-driven debugging.
33. What are the advantages of Concurrent Collections in Java?
List benefits like no need for external synchronization and fail-safe iterators.
34. What is the difference between deep copy and shallow copy?
Explain with examples the consequences on modifying original or copied objects.
35. Compare TreeMap, HashMap, and ConcurrentHashMap with examples.
Discuss order guarantees, thread safety, and performance trade-offs.
36. How do you handle Fail-Fast exceptions when modifying collections?
Discuss safe patterns like copying keys or using concurrent collections.
37. What is the use of ReentrantLock over synchronized block?
Explain flexibility with lock acquisition and ability to interrupt or timeout.
38. How to write a SQL query to find maximum marks per subject and sum?
Describe use of subquery and grouping logic.
39. How would you calculate minimum number of platforms required for trains?
Propose greedy algorithms using arrival/departure event sorting.
40. How to optimize finding missing positive numbers in constant space?
Explain swap-based bucket placement approach.
41. How do you avoid ConcurrentModificationException when modifying collections?
Use ConcurrentHashMap or iterate over copies of keys.
42. How does synchronized static vs non-static methods work with locking?
Describe object level locking vs class level locking.
43. What design changes help avoid deadlock scenarios?
Discuss lock ordering, lock timeout, and using tryLock.
44. How to validate different triangle types (equilateral, scalene) in SQL?
Use CASE WHEN logic based on side comparisons.
45. How do you print a matrix in spiral order?
List movement directions and boundary shrinking after each traversal.
46. How to maintain latest value while inserting keys using Java Streams?
Explain merge functions during toMap collector usage.
47. What corrections are required if a parent class lacks default constructor?
Child class must explicitly call a super constructor.
48. Why is it risky to mutate key fields of an object used in a HashSet?
Explain how it corrupts internal bucket structure and violates Set guarantees.
49. How to allow each element to appear at most twice while removing duplicates?
Use a two-pointer technique with counters.
50. What practical tips ensure designing classes for proper equality behavior?
Override equals, hashCode consistently, and avoid mutable fields.