Interview Questions for Full Stack Java Developer
Landing a full‑stack Java developer role requires a blend of deep back‑end expertise, solid front‑end skills, and the ability to tie everything together in a scalable architecture. Interviewers typically probe three areas: core Java fundamentals, ecosystem technologies (Spring, Hibernate, databases), and front‑end competencies (HTML/CSS/JavaScript, frameworks like React or Angular). Below is a comprehensive set of questions you can expect, grouped by topic, along with brief explanations of what interviewers are looking for and tips on how to answer them effectively.
Core Java Fundamentals
Object‑Oriented Programming
-
Explain the four pillars of OOP and give a Java example for each.
What they want: Clarity on encapsulation, inheritance, polymorphism, and abstraction. Show you can map concepts to real code (e.g., usingprivatefields,extends, method overriding, abstract classes or interfaces). -
What is the difference between
==and.equals()? When would you overrideequals()?
What they want: Understanding of reference vs. value comparison and the contract ofequals/hashCode. Mention overriding for domain objects used in collections likeHashSetor as keys inHashMap. -
Describe how Java achieves polymorphism. Provide an example of compile‑time and run‑time polymorphism.
What they want: Method overloading (compile‑time) vs. overriding (run‑time). Show you know the role of virtual method dispatch.
Collections & Generics
-
When would you choose
ArrayListoverLinkedList? What aboutHashSetvs.TreeSet?
What they want: Performance characteristics (O(1) random access vs. O(1) insert/delete at ends, ordering guarantees). -
Explain type erasure and its implications for generic code at runtime.
What they want: Awareness that generics are a compile‑time feature; you cannot instantiateTor create arrays of generic types without warnings.
Concurrency
-
What are the differences between
synchronizedblocks,ReentrantLock, andjava.util.concurrentatomic classes?
What they want: Knowledge of intrinsic locks vs. explicit locks, fairness, and lock‑free alternatives And it works.. -
How does the Java Memory Model guarantee visibility? Explain
volatileand its limits.
What they want: Understanding of happens‑before relationships, whyvolatileensures visibility but not atomicity for compound actions.
JVM & Performance
-
Describe the garbage collection process in HotSpot. Name at least two collectors and when you’d pick each.
What they want: Familiarity with young/old generations, serial, parallel, CMS, G1, ZGC; ability to match workload to collector (e.g., low‑latency vs. high‑throughput). -
What is a memory leak in Java? Give an example and how you’d detect it.
What they want: Awareness of unintentional object retention (static collections, listeners,ThreadLocal) and tools like VisualVM, MAT, or-XX:+HeapDumpOnOutOfMemoryError.
Spring Ecosystem
Core Spring
-
What is Dependency Injection (DI) and how does Spring implement it via constructor, setter, and field injection?
What they want: Explanation of IoC container, benefits of loose coupling, and why constructor injection is preferred for immutability and mandatory dependencies The details matter here.. -
Explain the difference between
@Component,@Service,@Repository, and@Controller.
What they want: Stereotype annotations, specialization for clarity, and Spring’s automatic exception translation for@RepositorySurprisingly effective.. -
How does Spring manage transactions? Contrast declarative (
@Transactional) vs. programmatic transaction management.
What they want: Knowledge of AOP proxies, propagation levels (REQUIRED,REQUIRES_NEW,NESTED), and rollback rules.
Spring MVC / REST
-
Describe the flow of a request through Spring MVC from
DispatcherServletto view resolution.
What they want: Handler mapping, adapter, handler execution, modelandview, view resolver. -
How do you version a REST API in Spring Boot? Discuss URI versioning, header versioning, and content negotiation.
What they want: Awareness of backward compatibility strategies and when each approach is appropriate. -
What is
@Validand how does Bean Validation work with Spring?
What they want: Integration of Hibernate Validator, constraint annotations (@NotNull,@Size), and handlingMethodArgumentNotValidException.
Spring Data & ORM
-
Explain the difference between JPA, Hibernate, and Spring Data JPA.
What they want: JPA as specification, Hibernate as implementation, Spring Data JPA as repository abstraction reducing boilerplate And that's really what it comes down to. Took long enough.. -
How does the
EntityManagerwork? What are the differences between persistence contexts (transaction‑scoped vs. extended)?
What they want: Lifecycle of managed entities, flush modes, and when to use@PersistenceContext(type = PersistenceContextType.EXTENDED)But it adds up.. -
When would you use a native query vs. JPQL? Give an example of each.
What they want: Awareness of JPQL portability vs. native SQL power for database‑specific features Which is the point..
Spring Boot & Microservices
-
What are Spring Boot starters and how do they simplify dependency management?
What they want: Opinionated defaults, auto‑configuration, and the concept of “starter” POMs. -
How does Spring Cloud support service discovery, load balancing, and circuit breaking?
What they want: Eureka/Consul, Ribbon/LoadBalancer, Resilience4j or Hystrix, and why these patterns matter in distributed systems Simple, but easy to overlook..
Front‑End Technologies
HTML / CSS
-
What is semantic HTML and why is it important for accessibility and SEO?
What they want: Use of<header>,<nav>,<article>,<section>, proper heading hierarchy, ARIA roles It's one of those things that adds up. And it works.. -
Explain the CSS box model and how
box-sizing: border‑boxchanges layout calculations.
What they want: Content, padding, border, margin; switching to border‑box makes width/height include padding and border. -
How do CSS Flexbox and Grid differ? When would you choose one over the other?
What they want: Flexbox for one‑dimensional layouts (rows or columns), Grid for two‑dimensional control; mention fallback for older browsers.
JavaScript / TypeScript
-
What are closures in JavaScript? Provide a practical example where they are useful.
What they want: Function retaining access to outer scope; examples: module pattern, event handlers, cur -
What are closures in JavaScript? Provide a practical example where they are useful.
What they want: Function retaining access to outer scope; examples: module pattern, event handlers, currying.
Answer: A closure is created when an inner function remembers and accesses variables from its enclosing scope even after the outer function has finished executing. This enables data encapsulation and state retention without exposing variables globally.function createCounter() { let count = 0; return { increment: () => ++count, getCount: () => count }; } const counter = createCounter(); console.log(counter.getCount()); // 0 counter.increment(); console.log(counter.getCount()); // 1Practical uses include the Module Pattern (to avoid polluting global namespace), event handlers that maintain private state, and functional programming techniques like currying That's the whole idea..
-
Explain the event loop, call stack, and callback queue in JavaScript.
What they want: Understanding how asynchronous operations are handled in a single-threaded environment.
Answer: JavaScript operates on a single thread using an event-driven concurrency model:- Call Stack: Executes synchronous code. Only one operation runs at a time.
- Callback Queue (or Task Queue): Holds messages from completed async tasks (e.g.,
setTimeout, I/O events). - Event Loop: Continuously checks if the call stack is empty. If so, it dequeues the next message from the callback queue and pushes it onto the call stack for execution.
This mechanism ensures non-blocking behavior despite being single-threaded.
-
What are Promises, async/await, and how do they improve upon traditional callback patterns?
What they want: Handling asynchronous logic more cleanly; avoiding "callback hell".
Answer:- Promises represent a value that may be available now, or in the future, or never. They provide
.then()and.catch()methods for chaining and error handling. - Async/await is syntactic sugar built on top of Promises, allowing developers to write asynchronous code that looks synchronous.
Example:
async function fetchData() { try { const response = await fetch('https://api.example.com/data'); const data = await response.json(); return data; } catch (error) { console.error("Error fetching data:", error); } }Benefits include flatter, readable code structure, better error handling via try/catch, and easier composition of asynchronous workflows compared to nested callbacks It's one of those things that adds up..
- Promises represent a value that may be available now, or in the future, or never. They provide
-
What is the difference between
let,const, andvarin terms of scope and reassignment?
What they want: Block scoping withlet/constvs. function scoping withvar; immutability semantics.
Answer:Feature varletconstScope Function-scoped Block-scoped Block-scoped Reassignment Yes Yes No Hoisting Declared & initialized as undefinedHoisted but not initialized (TDZ) Same as letUse
constby default,letwhen reassignment is needed, and avoidvarunless supporting very old environments Took long enough..
React
-
Describe the component lifecycle methods in React class components.
What they want: Mounting, updating, unmounting phases; legacy vs. modern hooks-based alternatives.
Answer: In React class components, lifecycle methods are grouped into three main phases:- Mounting:
constructor(),getDerivedStateFromProps(),render(),componentDidMount() - Updating:
getDerivedStateFromProps(),shouldComponentUpdate(),render(),getSnapshotBeforeUpdate(),componentDidUpdate() - Unmounting:
componentWillUnmount()
Modern React favors Hooks (useEffect,useState) which encapsulate similar logic declaratively without classes.
- Mounting:
-
What are React Hooks? Explain
useStateanduseEffect.
What they want: Functional components gaining statefulness and side-effect capabilities previously exclusive to class components.
Answer: Introduced in React 16.8, Hooks allow functional components to manage state and lifecycle behaviors.useState(initialValue)returns a state variable and a setter function.
Example:const [count, setCount] = useState(0);useEffect(callback, deps)performs side effects such as data fetching or subscriptions. It replacescomponentDidMount,componentDidUpdate, andcomponentWillUnmount.
Example:useEffect(() => { document.title = `Count: ${count}`; }, [count]); // Runs only when `count` changes
-
How does React handle component re-rendering? What role does reconciliation play?
What they want: Virtual DOM diffing algorithm, key usage in lists, performance optimization strategies.
Answer: When props or state change, React creates a new virtual tree and compares it with the previous one using a
using a reconciliation algorithm that efficiently updates the DOM by only changing what's necessary. Now, react then applies these updates to the real DOM in a batched, asynchronous manner to minimize performance bottlenecks. In real terms, this process, known as diffing, involves comparing the new virtual DOM tree with the previous one to identify changes. Worth adding: the role of reconciliation is crucial for performance; it ensures that components re-render only when needed, and keys are used in lists to help React track which items have changed, been added, or been removed. Optimization strategies like using React.memo, useCallback, or splitting components can further enhance performance by reducing unnecessary re-renders That's the part that actually makes a difference. Less friction, more output..
- Explain the concept of controlled vs. uncontrolled components in React.
What they want: Differences in form handling, with controlled components managing state via React and uncontrolled components relying on the DOM.
Answer: In React, form components can be controlled or uncontrolled.- Controlled components have their state managed by React. The component's value is driven by React state, and changes are handled with event handlers like
onChange. Example:const [value, setValue] = useState(''); return setValue(e.target.value)} />; - Uncontrolled components store their state in the DOM, similar to traditional forms. They are useful for simple cases where state isn't needed elsewhere. You can access the value via a ref. Example:
const inputRef = useRef(); const handleSubmit = () => console.log(inputRef.current.value); return ;
- Controlled components have their state managed by React. The component's value is driven by React state, and changes are handled with event handlers like
Conclusion
This article has covered foundational JavaScript concepts like var, let, and const, emphasizing modern best practices for variable declaration. It then delved into key React topics, including component lifecycle methods, Hooks for functional components, re-rendering mechanisms with reconciliation, and form handling strategies. By understanding these principles, developers can build more efficient and maintainable applications. As React continues to evolve, staying updated with these core ideas ensures strong and scalable solutions in dynamic web environments.