This document contains rephrased, concise versions of common Java and database interview questions.
- How does the Java ClassLoader work?
- Compare ArrayList, LinkedList, TreeSet, HashMap, and ConcurrentHashMap.
- Explain Try-with-resources and Java Streams (Intermediate vs Terminal operations,
flatMap,reducevscollect). - What happens if a class implements two interfaces with identical method signatures?
- Explain ACID properties, SOLID principles, Pessimistic vs Optimistic locking, and Eager vs Lazy loading.
- What are the different types of relationships between entities?
- What is a Native Query?
- Explain the
@Transactionalannotation and isolation levels in transactions. - What is the JPA/Hibernate Entity Life Cycle?
- JUnit: Difference between
@Mock,@InjectMocks, and@Spy. What is@ParameterizedTest? How to achieve 100% code coverage? - Differentiate between Static Binding and Dynamic Binding.
- Explain "IS-A" vs "HAS-A" relationships.
- What happens if one thread modifies a list while another thread is iterating over it?
- Explain
AtomicIntegerand whya++is not thread-safe. How does it achieve non-blocking thread safety? - Difference between Join and Subquery.
WHEREvsHAVINGclause. How to optimize a slow query? - What is Database Indexing?
- How to create an Immutable class? Why is
Stringimmutable in Java? - How to implement a Thread-safe Singleton class?
- How does HashMap handle collisions, and how can they be avoided?
- Why is only one
nullvalue allowed in aSet? - Compare
HashSet,LinkedHashSet, andTreeSet. - How does
ArrayListresize itself internally? - What is the time complexity of adding an element in the middle of an
ArrayListvs aLinkedList? - In inheritance, if a child method throws
FileNotFoundException, what exceptions can the parent method throw? - Difference between Method Overriding and Method Hiding (static methods).
- How does Java manage memory (JVM Heap vs Stack)?
- What is Cascading in JPA/Hibernate?
- Provide an example of
CascadeType.REMOVE. - Which AI tools (Copilot, Cursor, Claude) do you use for development?
- Compare
ExecutorService,CompletableFuture, and Virtual Threads. - Explain the internal working of
ConcurrentHashMap. - What are the built-in Functional Interfaces in Java 8?
- How to find all palindromes in a list of strings using Java 8 Streams?
- How to find the word with the second largest length in a sentence using Java 8?