Skip to content

Java Full Stack with React Interview Questions for 1 Year Experience

40 questions with answers for candidates with 1 year of experience — 18 easy, 22 medium.

What interviewers expect: 1 year experience

With one year of experience, interviewers expect you to have worked on real tickets. Questions move to how you used Spring Boot and JPA in your project, REST design, exception handling, basic testing and Git workflow. Expect a coding round on streams or collections, a SQL round and React questions on hooks and API integration. Be ready to describe a bug you fixed and how you tested it.

This set is weighted towards Core Java (8), React Frontend (6), REST APIs, Security and Microservices (5), JavaScript, HTML and CSS (5).

Spring Boot layers and annotations JPA mappings and queries React hooks and state Unit testing basics
Solved at this levelStart practicing
3 QUESTIONS FREESign up to unlock the full question bank and track your progress.Unlock every question and answer, then continue practising company-wise and package-wise.
3 questions free Unlock the rest in seconds
01

What does @SpringBootApplication do?

Save to ▾
Show answer
It is a convenience annotation combining three annotations. @SpringBootConfiguration marks the class as a configuration source. @EnableAutoConfiguration tells Boot to configure beans based on the classpath and properties, for example a DataSource when a JDBC driver is present. @ComponentScan scans the package of the main class and its sub-packages for components. That is why the main class should sit in the root package of your project.
02

What is CORS and how do you configure it for a React frontend?

Save to ▾
Show answer
CORS is a browser rule that blocks JavaScript from calling a different origin unless the server allows it with response headers like Access-Control-Allow-Origin. A React app on localhost:5173 calling an API on localhost:8080 is cross-origin. In Spring, define a CorsConfigurationSource bean with the allowed origins, methods and headers, and enable http.cors() in the security chain so preflight OPTIONS requests pass. Never use a wildcard origin together with credentials.
03

When should you use useMemo and useCallback?

Save to ▾
Show answer
useMemo caches the result of an expensive calculation until its dependencies change, such as filtering and sorting a big list. useCallback caches a function reference, which matters when passing callbacks to children wrapped in React.memo or used in effect dependencies. Do not wrap everything, because memoization itself has a cost. The React Compiler, released as stable in 2025, can add much of this memoization automatically in supported projects.
04

Write CSS for a product grid that shows 1 column on mobile, 2 on tablet and 4 on desktop.

Save to ▾
Show answer
.grid { display: grid; grid-template-columns: 1fr; gap: 16px; padding: 0 16px; } @media (min-width: 640px) { .grid { grid-template-columns: repeat(2, 1fr); } } @media (min-width: 1024px) { .grid { grid-template-columns: repeat(4, 1fr); } } /* Mobile-first: base styles for small screens, then widen. */
05

What is event delegation and why is it useful?

Save to ▾
Show answer
Events bubble up from the target element to its ancestors. With event delegation you attach one listener to a parent, such as a ul, and use event.target.closest('li') to find which child was clicked. This saves memory compared with a listener on every item and automatically works for items added later. It is commonly used for dynamic tables and lists. React uses a similar idea by attaching listeners at the root.
06

What is a closure in JavaScript? Give a practical use.

Save to ▾
Show answer
A closure is a function that remembers variables from the scope where it was created, even after that outer function has returned. For example, function counter() { let n = 0; return () => ++n; } returns a function that keeps its own private n. Closures are used for data privacy, function factories, event handlers, debounce and memoization, and React hooks rely on them. Stale closures in effects are a common bug when dependencies are missing.
07

What is the difference between WHERE and HAVING?

Save to ▾
Show answer
WHERE filters individual rows before grouping and cannot use aggregate functions. HAVING filters groups after GROUP BY and can use aggregates like COUNT or SUM. For example, SELECT dept, COUNT(*) FROM employees WHERE active = true GROUP BY dept HAVING COUNT(*) > 10. Put conditions in WHERE whenever possible because filtering earlier reduces the rows the database must group.
08

Show how to read a file safely using try-with-resources.

Save to ▾
Show answer
Path path = Path.of("data.txt"); try (BufferedReader reader = Files.newBufferedReader(path)) { String line; while ((line = reader.readLine()) != null) { System.out.println(line); } } catch (IOException e) { log.error("Could not read file", e); } // The reader is closed automatically, even if an exception occurs, // because BufferedReader implements AutoCloseable.
09

Compare promises and async/await.

Save to ▾
Show answer
A promise represents a value that will be available later, handled with then, catch and finally. async/await is syntax built on promises: an async function always returns a promise, and await pauses that function until the promise settles, so asynchronous code reads like synchronous code. Errors are handled with try/catch. Awaiting calls one by one is sequential, so use Promise.all for independent calls to run them in parallel.
10

Fetch a list of products from an API and show loading and error states.

Save to ▾
Show answer
function ProductList() { const [products, setProducts] = useState([]); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); useEffect(() => { const controller = new AbortController(); fetch('/api/products', { signal: controller.signal }) .then(res => { if (!res.ok) throw new Error('HTTP ' + res.status); return res.json(); }) .then(data => setProducts(data.content)) .catch(err => { if (err.name !== 'AbortError') setError(err.message); }) .finally(() => setLoading(false)); return () => controller.abort(); }, []); if (loading) return <p>Loading...</p>; if (error) return <p>Error: {error}</p>; return <ul>{products.map(p => <li key={p.id}>{p.name}</li>)}</ul>; }
11

What does the static keyword mean in Java?

Save to ▾
Show answer
static members belong to the class, not to an instance. A static variable has one copy shared by all objects, a static method can be called without creating an object and cannot use this, and a static block runs once when the class loads. Static nested classes do not hold a reference to the outer object. Common examples are utility methods like Math.max and constants declared as public static final.
12

When would you use the Context API and when a state library like Redux Toolkit or Zustand?

Save to ▾
Show answer
Context is good for passing low-frequency global values such as theme, language or the logged-in user without prop drilling. Every consumer re-renders when the context value changes, so it is not ideal for fast-changing data. Redux Toolkit or Zustand suit larger shared client state with many updates, selectors and dev tools. Server data like API responses is often best handled by TanStack Query, which adds caching and refetching.
13

What is React and what is the virtual DOM?

Save to ▾
Show answer
React is a JavaScript library for building user interfaces from reusable components. Components describe what the UI should look like for a given state, and React updates the browser DOM when the state changes. The virtual DOM is a lightweight in-memory tree of the UI. On each update, React compares the new tree with the previous one and applies only the minimum real DOM changes, which keeps updates efficient and the code declarative.
14

What are cascade types and orphanRemoval in JPA?

Save to ▾
Show answer
Cascade propagates operations from a parent to its children: PERSIST, MERGE, REMOVE, REFRESH, DETACH or ALL. For example, saving an Order with CascadeType.ALL also saves its items. orphanRemoval = true deletes a child row when it is removed from the parent's collection. Use them for true parent-child aggregates like order and items, but never cascade REMOVE on @ManyToOne or shared references like Category, or deleting one product could delete the category.
15

A report job builds a large string with + inside a loop and is very slow. What do you change?

Save to ▾
Show answer
Each + inside a loop creates a new String and copies the old content, giving roughly O(n squared) work. Replace it with one StringBuilder created before the loop, optionally with an initial capacity, and call append inside the loop. For joining collections, use String.join or Collectors.joining. For very large output, write directly to a BufferedWriter or stream instead of holding everything in memory.
16

How do you handle a requirement that is unclear or keeps changing?

Save to ▾
Show answer
Situation: a product manager asked for a discount feature with vague rules. Task: build it without wasting effort. Action: I wrote down my understanding with examples, asked specific questions about edge cases like stacking coupons, and built the rules as configurable data instead of hard-coded logic. I shared a small demo early for feedback. Result: two rule changes later in the sprint needed only configuration updates, not code changes.
17

Why does React need a key prop when rendering lists?

Save to ▾
Show answer
Keys help React match list items between renders, so it knows which items were added, removed or moved. Use a stable unique ID from the data, such as product.id. Using the array index as key causes bugs when items are reordered or deleted, because state and input values can attach to the wrong row. Keys only need to be unique among siblings, and they are not passed to the component as a prop.
18

The layout looks fine on desktop but breaks on mobile with horizontal scrolling. How do you debug it?

Save to ▾
Show answer
Check that the page has the viewport meta tag. Use browser device mode to find the element wider than the screen, often fixed widths in pixels, large images, long words or tables. Replace fixed widths with max-width: 100 percent, flexible units and flex-wrap, add overflow-wrap for long text and wrap wide tables in a scrollable container. Build mobile-first with media queries that add complexity for larger screens.
19

Users in different countries see wrong order times. How do you handle dates and time zones in Java?

Core JavaMedium
Save to ▾
Show answer
Store timestamps in UTC using Instant or OffsetDateTime, and map them to TIMESTAMP WITH TIME ZONE or a UTC timestamp column. Convert to the user's zone only when displaying, using ZonedDateTime with ZoneId such as Asia/Kolkata. Avoid java.util.Date and SimpleDateFormat, which are mutable and not thread-safe. Use DateTimeFormatter, send ISO-8601 strings in JSON and set hibernate.jdbc.time_zone to UTC.
20

Return only a few columns using an interface-based projection.

Save to ▾
Show answer
public interface ProductSummary { Long getId(); String getName(); BigDecimal getPrice(); } public interface ProductRepository extends JpaRepository<Product, Long> { List<ProductSummary> findByCategoryName(String category); @Query("select new com.shop.dto.PriceDto(p.name, p.price) from Product p where p.price < :max") List<PriceDto> cheaperThan(@Param("max") BigDecimal max); } // Projections select fewer columns and avoid loading full entities.
21

Your React app gets 403 Forbidden on POST requests to Spring Boot, but GET works. What is the likely cause?

Save to ▾
Show answer
With Spring Security enabled, CSRF protection is on by default and blocks POST, PUT and DELETE that lack a CSRF token, while GET is allowed. For a stateless JWT API, disable CSRF in the SecurityFilterChain. If you use session cookies, keep CSRF and send the token with CookieCsrfTokenRepository. Also check CORS, because a rejected preflight OPTIONS request or a missing role in authorization rules can produce the same symptom.
22

How do indexes improve performance, and when can they hurt?

Save to ▾
Show answer
An index, usually a B-tree, lets the database find rows without scanning the whole table, which speeds up WHERE, JOIN and ORDER BY on indexed columns. Indexes cost disk space and slow down INSERT, UPDATE and DELETE because each index must also be updated. They help little on low-selectivity columns like a boolean flag. Functions on the column, such as WHERE LOWER(email) = ?, or a leading wildcard in LIKE also prevent normal index use.
23

Describe a time you disagreed with a teammate during a code review.

Save to ▾
Show answer
Situation: a teammate used nested loops over two large lists to match records. Task: I felt it would be slow at production volume. Action: instead of just rejecting it, I wrote a quick benchmark showing the HashMap-based approach was much faster, and explained it calmly in a call. Result: he agreed, we merged the faster version, and we added a team guideline to back performance comments with data.
24

Using streams, group employees by department and count them.

Save to ▾
Show answer
Map<String, Long> countByDept = employees.stream() .collect(Collectors.groupingBy( Employee::getDepartment, Collectors.counting())); // Average salary per department: Map<String, Double> avgSalary = employees.stream() .collect(Collectors.groupingBy( Employee::getDepartment, Collectors.averagingDouble(Employee::getSalary))); // Use TreeMap::new as the second argument to get sorted keys.
25

How do you work with frontend developers and testers on API changes?

Save to ▾
Show answer
I agree on the API contract first using an OpenAPI spec or Swagger UI, so frontend and QA can start in parallel with mock data. I share example requests and error responses, and I tell the team early if a field must change. For example, in my last sprint I gave QA a Postman collection with test cases for every endpoint. This reduced back-and-forth and our feature passed testing on the first cycle.
26

A search query that used to take milliseconds now takes 10 seconds as data grew. How do you troubleshoot?

Save to ▾
Show answer
Get the exact SQL from logs or the slow query log and run EXPLAIN ANALYZE to see whether it does a full scan, a bad join order or a big sort. Check for missing or unused indexes, functions on indexed columns, implicit type conversions and outdated statistics. Add the right composite index, rewrite the query, select fewer columns and paginate. For text search, use a full-text index or a search engine instead of LIKE '%term%'.
27

What is the difference between JDK, JRE and JVM?

Save to ▾
Show answer
The JVM runs Java bytecode and handles memory, garbage collection and JIT compilation. The JRE is the JVM plus core class libraries needed to run programs. The JDK is the JRE plus development tools such as javac, jar, jshell and jdb. Since Java 11 a separate JRE is no longer shipped by Oracle, so developers install a JDK such as Temurin or Oracle JDK 17 or 21 and build smaller runtimes with jlink if needed.
28

What is the difference between Comparable and Comparator?

Save to ▾
Show answer
Comparable defines a class's natural ordering through compareTo, implemented inside the class itself, such as String or Integer. Comparator is a separate object with compare, so you can define many orderings without changing the class. Since Java 8, Comparator.comparing, thenComparing and reversed make multi-field sorting concise. Use Comparable for one obvious order and Comparator for business-specific sorting like price then rating.
29

You need a thread-safe singleton for a configuration loader. How do you implement it?

Core JavaMedium
Save to ▾
Show answer
The simplest safe options are an enum singleton or the holder idiom. With the holder idiom, a private static nested class holds the instance, and the JVM's class loading guarantees lazy, thread-safe initialisation without synchronization. Double-checked locking also works but needs a volatile field. In a Spring application you usually do not write singletons at all, because beans are singleton-scoped by default and the container manages them.
30

Why is String immutable in Java?

Save to ▾
Show answer
Once created, a String object cannot change. This allows the String pool to safely share literals, makes strings thread-safe without locking, lets hashCode be cached for fast HashMap keys, and protects security-sensitive values like file paths, class names and URLs from being changed after validation. Any operation such as concat or replace returns a new String, which is why heavy modification should use StringBuilder.
31

What are the entity lifecycle states in JPA?

Save to ▾
Show answer
A new or transient entity is just a Java object not known to the persistence context. A managed entity is attached to the context; changes are tracked and flushed automatically through dirty checking. A detached entity was managed but the context has closed, so changes are not tracked unless you merge it. A removed entity is scheduled for deletion on flush. Understanding these states explains why setters inside a transaction update the database without calling save.
32

Write a query to find duplicate email addresses in a users table and delete the extra rows.

Save to ▾
Show answer
-- Find duplicates SELECT email, COUNT(*) AS cnt FROM users GROUP BY email HAVING COUNT(*) > 1; -- Keep the lowest id, delete the rest (MySQL / PostgreSQL) DELETE FROM users u USING users k WHERE u.email = k.email AND u.id > k.id; -- PostgreSQL syntax -- Then add: ALTER TABLE users ADD CONSTRAINT ux_email UNIQUE (email);
33

How do derived query methods work in Spring Data JPA?

Save to ▾
Show answer
Spring Data parses the method name in a repository interface and builds the query. For example, findByEmailAndActiveTrue(String email) or findTop5ByCategoryOrderByPriceDesc(String category). Supported keywords include And, Or, Between, LessThan, Like, In, IsNull and OrderBy. Return types can be Optional, List, Page or Stream. For complex logic, use @Query with JPQL or native SQL, because very long method names become hard to read.
34

Write a query that shows daily sales with a running total for the month.

Save to ▾
Show answer
SELECT order_date, SUM(amount) AS daily_sales, SUM(SUM(amount)) OVER ( ORDER BY order_date ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) AS running_total FROM orders WHERE order_date >= DATE '2026-10-01' AND order_date < DATE '2026-11-01' GROUP BY order_date ORDER BY order_date;
35

Write a Java method to check whether a string is a palindrome, ignoring case and spaces.

Save to ▾
Show answer
static boolean isPalindrome(String s) { String clean = s.replaceAll("\\s+", "").toLowerCase(); int i = 0, j = clean.length() - 1; while (i < j) { if (clean.charAt(i++) != clean.charAt(j--)) { return false; } } return true; } // Two pointers give O(n) time and O(n) space for the cleaned copy. // isPalindrome("Nurses Run") returns true.
36

Create a scheduled job that runs every night at 2 AM in Spring Boot.

Save to ▾
Show answer
@SpringBootApplication @EnableScheduling public class App { } @Component public class CleanupJob { private final SessionRepository repo; public CleanupJob(SessionRepository repo) { this.repo = repo; } @Scheduled(cron = "0 0 2 * * *", zone = "Asia/Kolkata") public void removeExpiredSessions() { repo.deleteByExpiresAtBefore(Instant.now()); } } // With several instances, use ShedLock so only one runs the job.
37

Compare monolithic and microservices architecture.

Save to ▾
Show answer
A monolith is one deployable application. It is simpler to build, test and debug, and suits small teams and early products. Microservices split the system into independently deployable services owned by separate teams, such as orders, payments and inventory, each with its own database. They allow independent scaling and releases but add network latency, distributed data, monitoring and deployment complexity. Many teams start with a modular monolith and split only when needed.
38

What is the biggest full stack project you have built?

Save to ▾
Show answer
I built a job portal using React with Vite, Spring Boot 3, Spring Security with JWT and MySQL. Recruiters could post jobs and candidates could apply and track status. I designed the REST APIs, implemented role-based access, added pagination and search, and used TanStack Query on the frontend. I deployed it with Docker and a CI pipeline. The hardest part was file upload for resumes, which I solved with pre-signed object storage URLs.
39

What are fail-fast and fail-safe iterators?

Save to ▾
Show answer
Fail-fast iterators, used by ArrayList and HashMap, track a modification count and throw ConcurrentModificationException if the collection is structurally changed during iteration, except through the iterator's own remove. Fail-safe or weakly consistent iterators, used by CopyOnWriteArrayList and ConcurrentHashMap, work on a snapshot or tolerate concurrent changes and never throw that exception, but they may not show the latest updates.
40

What is Spring Boot and how is it different from the Spring Framework?

Save to ▾
Show answer
Spring Framework provides dependency injection, MVC, data access and transactions, but traditionally needed a lot of manual configuration and an external server. Spring Boot sits on top of Spring and adds auto-configuration, starter dependencies, an embedded Tomcat, Jetty or Undertow server, externalised configuration and production features like Actuator. You can run an application as a single executable jar with java -jar, which makes it ideal for microservices and containers.

Frequently asked questions

What is asked in Java Full Stack with React interviews for 1 year of experience?

With one year of experience, interviewers expect you to have worked on real tickets. Questions move to how you used Spring Boot and JPA in your project, REST design, exception handling, basic testing and Git workflow. Expect a coding round on streams or collections, a SQL round and React questions on hooks and API integration. Be ready to describe a bug you fixed and how you tested it.

How many questions should I practise before a Java Full Stack with React interview?

Work through all 40 questions here, then the company-wise sets for the employers you are targeting. Quality matters more than count: be able to explain why each answer is right.

Which topics matter most for 1 year of experience?

Focus first on Spring Boot layers and annotations, JPA mappings and queries, React hooks and state, Unit testing basics.