Java QB
Java QB
(Remember)
10. What is the difference between shallow and deep cloning? (Understand)
18. What is the role of the 'public' access modifier in Java? (Understand)
12. What is the difference between method overloading and method overriding?
(Understand)
19. How does implementing an interface differ from extending a class? (Understand)
1. Exception Handling:
5. What is the role of the 'finally' block in Java exception handling? (Understand)
2. Packages:
19. How does package organization help in large Java projects? (Understand)
6. How do you use a for-each loop to iterate over a string in Java? (Apply)
4. Useful Classes:
11. Which class is used to represent date and time in Java 8 and later? (Remember)
12. What is the primary use of the Scanner class in Java? (Understand)
13. What package contains classes for input/output operations in Java? (Remember)
15. Name two classes used for reading from files in Java. (Remember)
5. Analyze:
7. Compare and contrast the use of BufferedReader and Scanner for reading input
in Java. (Analyze)
9. Investigate the impact of using different buffer sizes on file I/O performance in
Java. (Analyze)
10. Evaluate:
11. 9. Evaluate the pros and cons of using checked vs. unchecked exceptions in a
large-scale Java application. (Evaluate)
12. 10. Assess the suitability of Java's built-in serialization mechanism for long-term
data storage. (Evaluate)
13. 11. Judge the effectiveness of using the Observer pattern (Observable and
Observer classes) in a real-time system. (Evaluate)
14. 12. Critique the use of regular expressions for complex string parsing tasks in
terms of readability and maintainability. (Evaluate)
15. Create:
16. 13. Design a custom exception hierarchy for a banking application, considering
different types of potential errors. (Create)
17. 14. Develop a utility class that provides advanced array manipulation methods
not available in the standard Java Arrays class. (Create)
18. 15. Construct a file encryption/decryption system using Java I/O and security
APIs. (Create)
19. 16. Create a custom annotation and processor to generate boilerplate code for
data classes in Java. (Create)
1. (Apply) Write a Java method that checks if a given string is a valid palindrome,
considering only alphanumeric characters and ignoring case.
2. (Analyze) Explain the difference between `==` and `.equals()` when comparing
objects in Java. Provide an example to illustrate your answer.
3. (Apply) Implement a method to find the intersection of two integer arrays (i.e.,
common elements) using Java Collections.
4. (Understand) Describe the purpose of the `final` keyword in Java and provide
examples of its use with variables, methods, and classes.
9. (Apply) Write a Java method that uses a lambda expression to filter even
numbers from a list of integers.
10. (Analyze) Discuss the differences between `ArrayList` and `LinkedList` in terms
of their internal structure and performance characteristics.
11. (Apply) Implement a generic method in Java that swaps two elements in an
array of any type.
12. (Understand) Describe the purpose and usage of the `static` keyword in Java,
providing examples for variables and methods.
13. (Apply) Write a Java program that demonstrates the use of a `TreeMap` to store
and retrieve key-value pairs in sorted order.
14. (Analyze) Explain the concept of autoboxing and unboxing in Java. Provide
examples where these features are implicitly used.
15. (Apply) Implement a simple thread-safe singleton class in Java using double-
checked locking.
1. (Apply) Write a Java method that reverses a given string without using any
built-in reverse functions.
3. (Apply) Implement a method that finds the second largest element in an integer
array.
6. (Understand) Describe the purpose of the `super` keyword in Java and provide
an example of its usage in method overriding.
7. (Apply) Implement a simple generic class in Java that can store and retrieve
elements of any type.
8. (Analyze) Explain the concept of method overloading in Java and how it differs
from method overriding. Provide code examples for both.
10. (Understand) Describe the purpose and usage of the `static` keyword in Java,
providing examples for both methods and variables.
11. (Apply) Implement a Java method that uses a lambda expression to sort a list of
strings based on their length.
12. (Analyze) Compare the use of `StringBuilder` and `StringBuffer` in Java. When
would you choose one over the other?
13. (Apply) Write a Java program that demonstrates the use of the `Comparable`
interface to sort custom objects.
14. (Understand) Explain the concept of polymorphism in Java and provide a simple
code example to illustrate it.
15. (Apply) Implement a method in Java that uses a regular expression to validate
an email address.
1. Write a Java method that reverses a given string without using any built-in
reverse functions.
3. Implement a method that finds the second largest element in an integer array.
5. Write a Java program that demonstrates the use of a HashMap to count the
frequency of words in a given string.
6. Implement a generic class called `Pair<T, U>` that can store two elements of
different types. Include methods to get and set these elements. Demonstrate its
usage with different data types.
7. Write a Java program that reads data from a text file, processes it to count the
occurrences of each word, and writes the results to another file. Use appropriate
exception handling and try-with-resources.
8. Explain the concept of multithreading in Java. Write a program that creates two
threads: one that prints even numbers and another that prints odd numbers up
to a given limit, ensuring they print in sequence.
10. Design a simple banking system using object-oriented principles in Java. Include
classes for Bank, Account (abstract), SavingsAccount, and CurrentAccount.
Implement methods for deposit, withdraw, and calculate interest. Use
inheritance, polymorphism, and exception handling where appropriate.
Demonstrate the usage of your classes in a main method.
11. Create a student management system that allows adding students, courses, and
managing student enrollments. Use appropriate data structures (e.g., ArrayList,
HashMap) to store student and course information. Implement methods to:
a) Add a new student
b) Add a new course
c) Enroll a student in a course
d) Display all courses a student is enrolled in
e) Display all students enrolled in a specific course
20. Include proper exception handling and demonstrate the functionality in a main
method.
12. Implement a multi-threaded chat server and client application in Java. The
server should be able to handle multiple client connections concurrently. Clients
should be able to send messages to all connected clients or to a specific client. Use
socket programming and proper synchronization techniques. Demonstrate the
application's functionality with at least three concurrent client connections.
13. Design and implement a generic graph data structure in Java. Include methods
for adding vertices and edges, performing depth-first search (DFS) and breadth-
first search (BFS), and finding the shortest path between two vertices (e.g., using
Dijkstra's algorithm). Demonstrate the usage of your graph implementation with
both directed and undirected graphs, using different data types for vertices.