JAVA QUESTIONS
JAVA QUESTIONS
6. Advanced Java
61. Explain the concept of reflection in Java.
62. What is Java Native Interface (JNI)?
63. Explain the difference between Callable and Runnable.
64. What is Java RMI?
65. How does the ExecutorService framework work?
66. What are annotations in Java?
67. Explain the working of the Fork/Join framework.
68. How does the Java NIO package differ from the IO package?
69. What is a CompletableFuture?
70. What is the role of the Atomic classes in Java?
8. Spring Framework
81. What is the Spring Framework?
82. Explain dependency injection and inversion of control.
83. What are Spring beans, and how are they configured?
84. What is the difference between @Component, @Service, and @Repository?
85. Explain the concept of Spring Boot.
86. How is Spring MVC different from Spring Boot?
87. What is the purpose of Spring AOP?
88. Explain the role of the @Transactional annotation.
89. What are the main features of Spring Security?
90. How does Spring handle REST APIs?
9. Programming Challenges
91. Write a program to implement LRU Cache.
92. Develop a program to find the longest substring without repeating characters.
93. Implement a system to simulate a ticket booking process with multithreading.
94. Write a program to parse and process JSON data.
95. Develop a program to solve the producer-consumer problem.
96. Write a program to simulate an elevator system.
97. Implement a Tic-Tac-Toe game in Java.
98. Write a program to validate a Sudoku puzzle.
99. Develop a chess game using object-oriented principles.
100. Create a simple chat application using Java sockets.
1. Data Structures and Algorithms
1. Implement a Trie data structure with insert, search, and delete operations.
2. Write a program to solve the N-Queens problem.
3. Implement a self-balancing AVL Tree.
4. Write a program to find the shortest path in a weighted graph (Dijkstra’s algorithm).
5. Implement a program to find articulation points in a graph.
6. Write a program to merge two balanced binary search trees into one.
7. Implement a Red-Black Tree.
8. Solve the Traveling Salesman Problem using dynamic programming.
9. Implement a program to find all strongly connected components in a graph.
10. Write a program to find the maximum flow in a network using the Ford-Fulkerson
algorithm.
3. System Design
21. Design a URL shortener like TinyURL.
22. Implement a rate-limiting algorithm (e.g., Token Bucket Algorithm).
23. Design a distributed file system.
24. Write a program to implement a message queue.
25. Design and implement a parking lot system.
26. Build a library management system with object-oriented design.
27. Implement a distributed key-value store.
28. Design an elevator system with concurrency.
29. Implement a notification service with retry mechanisms.
30. Design a real-time chat application using sockets.
4. String Manipulation
31. Write a program to find all permutations of a string.
32. Implement a program to find the longest palindromic substring.
33. Write a program to perform wildcard pattern matching.
34. Implement a program to find the minimum number of edits to convert one string into
another (edit distance problem).
35. Write a program to group anagrams together.
36. Implement a function to find all possible word breaks of a string.
37. Write a program to implement a suffix tree.
38. Solve the KMP (Knuth-Morris-Pratt) pattern-matching algorithm.
39. Write a program to check if two strings are scrambled versions of each other.
40. Implement the Boyer-Moore algorithm for pattern matching.
5. Mathematical Problems
41. Implement a program to find the square root of a number without using built-in functions.
42. Write a program to generate all possible subsets of a set.
43. Implement a program to solve linear equations using matrix operations.
44. Write a program to compute the power of a number using fast exponentiation.
45. Implement a program to generate all prime numbers using the Sieve of Eratosthenes.
46. Write a program to solve the subset sum problem.
47. Implement the Gaussian elimination method to solve a system of linear equations.
48. Write a program to find the largest number that can be formed by rearranging digits.
49. Implement a program to find all integer solutions to a given equation.
50. Solve the integer knapsack problem using dynamic programming.
7. Dynamic Programming
61. Solve the Longest Increasing Subsequence problem.
62. Write a program to find the number of ways to partition a set into subsets.
63. Implement a program to solve the coin change problem.
64. Write a program to maximize profit from a rod cutting problem.
65. Solve the matrix chain multiplication problem.
66. Write a program to find the maximum sum of a subarray (Kadane’s algorithm).
67. Implement a program to solve the Boolean parenthesization problem.
68. Write a program to find the number of unique paths in a grid with obstacles.
69. Solve the problem of finding the minimum number of jumps to reach the end of an array.
70. Implement a program to find the longest common subsequence of two strings.
1. Concurrent Skip List: Implement a thread-safe skip list for fast searches.
2. Immutable Trie: Build an immutable trie for storing dictionary words.
3. Dynamic Interval Tree: Create an interval tree that supports dynamic insertions and
deletions.
4. Memory-Efficient Sparse Matrix: Implement a sparse matrix using hash maps.
5. Graph with Union-Find: Solve a problem to check if adding an edge creates a cycle.
2. Algorithms
6. Generalized Suffix Array: Build a suffix array for multiple strings to solve substring
search queries efficiently.
7. String Similarity: Implement the Levenshtein Distance algorithm with optimized
memory usage.
8. Arbitrary Precision Arithmetic: Implement addition, subtraction, multiplication, and
division for extremely large numbers.
9. Convex Hull Optimization: Solve a geometric problem to find the minimum area
polygon containing all points.
10. Hopcroft-Karp Algorithm: Implement this algorithm for finding the maximum matching
in a bipartite graph.
11. Asynchronous Task Manager: Build a task manager to schedule and run jobs with
dependency resolution.
12. Lock-Free Queue: Implement a queue with atomic operations for lock-free thread
safety.
13. Parallel Matrix Multiplication: Multiply two matrices using Java's ForkJoinPool.
14. Deadlock Detection: Write a program that simulates a system and detects deadlocks in
a multithreaded environment.
15. Message Broker System: Design a lightweight message broker to queue and distribute
tasks between threads.
5. Machine Learning
21. Naive Bayes Classifier: Implement a text classification system using Naive Bayes.
22. K-Means Clustering: Perform clustering on a set of 2D points.
23. Gradient Descent: Optimize a function using gradient descent from scratch.
24. Decision Tree: Build a decision tree classifier using recursion.
25. Recommendation Engine: Implement collaborative filtering for user-item
recommendations.
26. Lazy Evaluation: Implement a system that performs lazy evaluation on a sequence of
chained operations.
27. Memoized Fibonacci: Create a highly optimized Fibonacci function using closures and
memoization.
28. Immutable Data Structure: Build a purely functional stack or queue.
29. Currying and Composition: Write a utility that composes and curries functions
dynamically.
30. Deep Object Merge: Implement a recursive deep merge for complex nested objects.
2. Algorithms
31. Quickselect Algorithm: Implement Quickselect to find the k-th smallest element in an
unsorted array.
32. Sparse Table: Solve range queries (min/max) with preprocessing using a sparse table.
33. Trie Search: Build an auto-complete feature with a trie for fast prefix searches.
34. A Pathfinding*: Implement the A* algorithm to find the shortest path in a grid.
35. Event Debouncing/Throttling: Build debouncing and throttling utilities for optimized
event handling.
3. Asynchronous Programming
36. Promise Pool: Create a pool of promises with a configurable concurrency limit.
37. Rate Limiter: Design a rate-limiting system for API requests.
38. Async Retry: Implement a function that retries asynchronous tasks with exponential
backoff.
39. Task Scheduler: Build a task scheduler that runs jobs based on delays and priorities.
40. Custom Event Emitter: Create an event emitter class with on, off, and emit methods.
4. Web Development
41. Virtual DOM: Build a minimal virtual DOM implementation and compare it with the actual
DOM.
42. State Management System: Create a Redux-like state management library.
43. Custom Hooks: Build React-style hooks, such as useState and useEffect, from
scratch.
44. SSR Framework: Implement a simple server-side rendering framework for React
components.
45. WebSocket Chat Application: Design a real-time chat system using WebSocket.
5. Real-World Simulations
46. Game of Life: Build Conway's Game of Life with a visual grid interface.
47. Maze Solver: Solve a randomly generated maze using DFS/BFS and visualize the
solution.
48. Weather App: Create a weather dashboard using data from an external API.
49. Typeahead Search: Implement a typeahead search with API call optimization using
debouncing.
50. AI Bot for Games: Write an AI bot to play Tic-Tac-Toe using the minimax algorithm.
7. Machine Learning
56. Linear Regression: Build a linear regression model in Java and visualize results using
JavaScript.
57. K-Nearest Neighbors: Implement KNN in Java and visualize the clusters using
JavaScript.
58. Decision Trees: Use Java for training a decision tree and JavaScript for prediction
visualization.
59. Real-Time Analytics: Process sensor data in Java and visualize live stats with
JavaScript.
60. Neural Network: Build a simple neural network in Java and visualize its learning
process using JavaScript.
9. Cryptography
10. Optimization
71. Solve the Vehicle Routing Problem (VRP) using a heuristic algorithm.
72. Optimize database queries in Java and visualize performance in JavaScript.