0% found this document useful (0 votes)
6 views

JAVA QUESTIONS

The document outlines a comprehensive curriculum covering various aspects of Java programming, including core concepts, object-oriented programming, data structures, algorithms, and advanced topics. It includes practical programming challenges, system design problems, and advanced problems in both Java and JavaScript. The content is structured into sections that progressively build on knowledge and skills necessary for proficient programming and software development.

Uploaded by

REVATHI
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

JAVA QUESTIONS

The document outlines a comprehensive curriculum covering various aspects of Java programming, including core concepts, object-oriented programming, data structures, algorithms, and advanced topics. It includes practical programming challenges, system design problems, and advanced problems in both Java and JavaScript. The content is structured into sections that progressively build on knowledge and skills necessary for proficient programming and software development.

Uploaded by

REVATHI
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

1.

Core Java (Basic Concepts)


1. What are the features of Java?
2. Explain the JVM, JRE, and JDK.
3. Describe the differences between == and .equals() in Java.
4. What is the difference between a class and an object?
5. Explain the concept of constructors in Java.
6. What are access modifiers? Explain with examples.
7. Describe the difference between static and non-static members in Java.
8. What is method overloading and overriding? Provide examples.
9. Explain the difference between an abstract class and an interface.
10. What are default methods in interfaces?
11. How is memory managed in Java?
12. What is garbage collection in Java?
13. Explain the final, finally, and finalize keywords.
14. What is the difference between checked and unchecked exceptions?
15. Explain the concept of multithreading in Java.
16. What is the volatile keyword?
17. What is a thread pool, and how is it managed in Java?
18. Explain the concept of lambda expressions in Java.
19. What are functional interfaces?
20. Explain the concept of streams in Java.

2. Object-Oriented Programming (OOP)


21. What is encapsulation? Provide an example.
22. How is inheritance implemented in Java?
23. Explain polymorphism with examples.
24. What is the purpose of the super keyword?
25. What is an abstract class? When do you use it?
26. Can a class extend multiple classes in Java? Why or why not?
27. What is the difference between IS-A and HAS-A relationships?
28. What are inner classes in Java?
29. Explain the concept of method hiding in Java.
30. What are anonymous classes?

3. Data Structures in Java


31. What are the main types of data structures supported by Java Collections?
32. Explain the difference between ArrayList and LinkedList.
33. What is a HashMap? How does it work internally?
34. What is the difference between HashSet and TreeSet?
35. How is a Queue implemented in Java?
36. What is a PriorityQueue, and how does it work?
37. Explain the concept of generics in Java.
38. What is the difference between Comparable and Comparator?
39. How do you implement a custom LinkedList in Java?
40. Write a program to reverse a linked list.

4. Algorithms and Problem Solving


41. Write a program to find the factorial of a number.
42. Implement a Fibonacci sequence in Java.
43. Write a program to find the greatest common divisor (GCD) of two numbers.
44. Implement the binary search algorithm.
45. Write a program to sort an array using bubble sort.
46. Implement a program to check if a string is a palindrome.
47. Write a program to detect a cycle in a graph.
48. Implement a binary tree in Java.
49. Write a program to perform depth-first search (DFS).
50. Implement a queue using two stacks.

5. Java Libraries and APIs

51. What are the main classes in the java.util package?


52. Explain the purpose of the java.io package.
53. How does the java.time package handle dates and times?
54. What is the purpose of the java.net package?
55. How is JSON handled in Java? Provide examples.
56. What is the purpose of the Optional class?
57. Explain the difference between String, StringBuilder, and StringBuffer.
58. How does the Math class work in Java?
59. What is the purpose of the Properties class?
60. How do you read and write files in Java?

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?

7. Database Connectivity (JDBC)


71. What is JDBC? Explain its architecture.
72. How do you connect to a database using JDBC?
73. What is the purpose of the DriverManager class?
74. Explain the different types of JDBC drivers.
75. What are prepared statements, and why are they used?
76. How do you execute a stored procedure in Java?
77. What is a transaction in JDBC? How do you manage it?
78. Explain the purpose of batch processing in JDBC.
79. What is connection pooling, and how is it implemented?
80. How do you handle SQL exceptions 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.

2. Multithreading and Concurrency


11. Implement a thread-safe Singleton design pattern.
12. Write a program to implement a producer-consumer problem using semaphores.
13. Implement the Readers-Writers problem.
14. Design a thread-safe bounded blocking queue.
15. Write a program to solve the dining philosophers problem.
16. Implement a cyclic barrier.
17. Write a program to implement a custom thread pool.
18. Implement a parallel merge sort algorithm.
19. Write a program to simulate a bank transaction system with multiple threads.
20. Design a concurrent cache using ConcurrentHashMap.

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.

6. Advanced Data Structures


51. Implement a Fenwick Tree (Binary Indexed Tree).
52. Write a program to implement a segment tree with range queries.
53. Implement a program to simulate an LFU (Least Frequently Used) cache.
54. Write a program to build a persistent data structure.
55. Implement a program to find the minimum spanning tree using Kruskal’s algorithm.
56. Write a program to find the LCA (Lowest Common Ancestor) in a binary tree.
57. Implement a sparse table for range queries.
58. Write a program to construct and query a Cartesian tree.
59. Implement a 2D Fenwick Tree.
60. Write a program to implement a skip list.

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.

8. Games and Simulations


71. Write a program to simulate the Minesweeper game.
72. Implement the Tic-Tac-Toe game with an AI opponent using the minimax algorithm.
73. Write a program to simulate a snake game.
74. Implement the Sudoku solver using backtracking.
75. Write a program to play Connect Four.
76. Implement a Chess engine with basic moves and checks.
77. Write a program to simulate Conway’s Game of Life.
78. Implement the Hangman game.
79. Write a program to solve the Rubik’s Cube.
80. Implement a Monopoly game simulation.

9. File and Data Processing


81. Write a program to merge multiple large sorted files.
82. Implement a program to compress and decompress files using Huffman encoding.
83. Write a program to detect duplicate files in a directory.
84. Implement a program to parse and validate large JSON files.
85. Write a program to perform a full-text search on a document.
86. Implement a program to extract and count unique words from a large text file.
87. Write a program to simulate a version control system.
88. Implement a spell checker using a dictionary file.
89. Write a program to compare the contents of two large files efficiently.
90. Implement a system to track changes in a file (like git diff).

10. Miscellaneous Challenges


91. Write a program to find the largest rectangle in a histogram.
92. Implement a program to solve a maze using DFS and BFS.
93. Write a program to find the skyline of a city using a sweep line algorithm.
94. Implement a program to schedule tasks with deadlines and profits.
95. Write a program to detect plagiarism in two documents.
96. Implement a program to find the convex hull of a set of points.
97. Write a program to generate random numbers with a given probability distribution.
98. Implement a real-time stock price ticker.
99. Write a program to evaluate a mathematical expression given as a string.
100. Implement a real-time leader board with dynamic updates.
Advanced Problems in Java
1. Data Structures

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.

3. Multithreading and Concurrency

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.

4. System Design and Simulations

16. Distributed Key-Value Store: Implement a consistent hashing-based distributed key-


value store.
17. Search Autocomplete System: Design a prefix-based search autocomplete with
caching.
18. Stock Price Simulator: Build a real-time stock price generator and calculate moving
averages.
19. Blockchain Simulation: Create a simplified blockchain with proof-of-work and
transaction validation.
20. Database Indexing: Simulate a database index with B+ Tree and perform search
operations.

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.

Advanced Problems in JavaScript


1. Functional Programming

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.

Cross-Language Challenges (Java and JavaScript)


6. Advanced Programming Challenges

51. Polymorphic Serialization: Serialize and deserialize a polymorphic object hierarchy in


both Java and JavaScript.
52. Dynamic Code Execution: Implement a system that evaluates user-submitted code
securely.
53. Graph Visualization: Use Java for backend graph processing and JavaScript (D3.js) for
frontend visualization.
54. Web Scraper: Build a scraper in Java and display the data interactively using
JavaScript.
55. Data Synchronization: Sync large JSON datasets efficiently between a Java backend
and JavaScript frontend.

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.

Very Hard Problems (Out-of-the-Box)


61. Compiler Design: Write a lexer, parser, and evaluator for a simple programming
language.
62. Custom JavaScript Engine: Build a mini JavaScript interpreter with eval, scope, and
closures.
63. Blockchain Validator: Write a system that validates transactions across nodes (Java
backend, JavaScript UI).
64. Distributed Event System: Build a real-time distributed event-handling system for IoT
devices.
65. 3D Game Engine: Use WebGL (JavaScript) for rendering and Java for backend physics
simulation.

General Themes for Hard Problems


8. Games

66. Build a full-featured chess engine with an AI opponent.


67. Create a multiplayer card game system with real-time syncing.
68. Simulate a 3D Rubik’s Cube and implement a solver.

9. Cryptography

69. Implement RSA encryption/decryption from scratch in Java.


70. Create a password manager with salted hashing in JavaScript.

10. Optimization

71. Solve the Vehicle Routing Problem (VRP) using a heuristic algorithm.
72. Optimize database queries in Java and visualize performance in JavaScript.

You might also like