Question - Bank Java Oops
Question - Bank Java Oops
2 Marks question.
1. Explain the architecture of the Java platform, including JVM, JRE, and JDK. How do
these components interact during the execution of a Java program?
(Include a labeled diagram for better clarity.)
2. Discuss the key features of Java that make it suitable for modern software development.
Provide examples where applicable.
3. Describe the structure of a Java source file. Write a simple Java program and explain the
compilation and execution steps involved.
4. What is bytecode? Explain the process by which Java achieves platform independence
using the JVM.
5. Differentiate between static and instance members in Java. Illustrate with a code
example that uses both.
6. Explain the different types of access specifiers in Java. Provide an example showing how
access levels affect class, method, and variable accessibility.
7. Write a Java program to demonstrate the use of arrays and control flow statements.
Explain the logic of your program.
8. What is inheritance in Java? Explain with an example. Also, differentiate between
method overloading and method overriding.
9. 9.Explain the concepts of abstraction and polymorphism in Java. Use appropriate
examples involving interfaces and abstract classes.
10. Discuss encapsulation and its importance in Java. How does it support data hiding and
security? Provide a code example.
11. What are packages in Java? How are they created and used? Explain with a code example
and show how to compile and run a program using a user-defined package.
12. Differentiate between import and static import with suitable examples. Also, explain
the naming convention for packages and the purpose of CLASSPATH.
13. What is a constructor in Java? How is it different from a method? Explain different types
of constructors (default, parameterized, copy constructor) with suitable examples.
14. Write a Java program that demonstrates the use of constructor overloading. Explain how
Java determines which constructor to call during object creation.
15. Discuss the concept of constructor chaining in Java using this() and super(). Write a
program that shows constructor chaining within a class and between a superclass and
subclass.
16. How does Java handle constructor inheritance in subclassing? Can a subclass inherit
constructors from its superclass? Justify your answer with an example.
17. Explain the importance of constructors in object initialization. What happens if you don’t
explicitly define a constructor in a class? Provide an example to support your
explanation.
18. Describe multiple inheritance, write a program to achieve multiple inheritance in java.
1. Explain the control flow of exception handling in Java using try, catch, finally,
throw, and throws.
o Include a program that demonstrates how each is used.
2. Differentiate between checked and unchecked exceptions with examples.
o Give two examples of each.
o Explain how Java handles both at compile-time and runtime.
3. What is the purpose of creating user-defined exceptions in Java? How can you
create and use one?
o Write a program demonstrating a custom exception for invalid input.
4. How does the JVM react when an exception is not caught by the program?
o Describe the default exception handling mechanism.
o Give an example program where an exception is not handled.
5. Explain the difference between byte streams and character streams in Java.
o Name at least two classes used for each.
o Write a program that reads and writes data to a file using either stream.
6. Write a Java program that reads text from one file and writes it into another using
FileReader and FileWriter.
o Explain how file handling works in Java with character streams.
7. What are the different states in the life cycle of a Java thread? Explain with a
diagram.
Write a Java program that demonstrates thread synchronization using the synchronized
keyword.
11. Explain the Exception Hierarchy in Java. How are exceptions categorized?
Distinguish between Throwable, Exception, Error, Checked, and Unchecked
exceptions with examples.
1. Explain the concept of functional interfaces and lambda expressions in Java. How
do they simplify code? Write a Java program using a functional interface and a
lambda expression.
2. What is the Stream API in Java? Explain its advantages and basic operations like filter(),
map(), and collect() with an example.
3. Compare default methods and static methods in Java interfaces. Why were default
methods introduced in Java 8? Provide examples.
4. Describe the purpose and syntax of try-with-resources in Java. How does it differ
from traditional try-catch-finally for resource management? Include a program to
demonstrate.
5. What are records in Java? How do they reduce boilerplate code? Write a sample Java
program using a record and explain its benefits.
6. Explain local variable type inference using var in Java. What are its advantages and
limitations? Include a code example to demonstrate its use.
7. Discuss the Java Module System introduced in Java 9. Why was it introduced and how
does it help in large applications? Provide the syntax to define a module.
8. What are sealed classes in Java? How do they provide better control over
inheritance? Write a sample code using a sealed class and permitted subclasses.
9. What are switch expressions in Java? How are they different from traditional switch
statements? Illustrate your answer with a suitable code example.
1. Explain the hierarchy of the Java Collections Framework. Describe the major interfaces
and their commonly used classes with suitable examples.
2. Compare and contrast ArrayList, LinkedList, Vector, and Stack in terms of performance,
use cases, and internal structure. Provide examples.
3. What is the difference between HashMap, TreeMap, LinkedHashMap, and Hashtable?
Explain with examples where each should be used.
4. . Explain the working and features of the Set interface in Java. Compare
HashSet, LinkedHashSet, and TreeSet with examples.
5. Describe how sorting is achieved in Java Collections using Comparable and Comparator
interfaces. Provide code examples for both.
6. Explain the Queue interface and its implementation in Java. Discuss the
working of common queue classes with examples.
7. What is the role of the Iterator interface in Java Collections? How is it different
from ListIterator? Provide code examples.
8. Explain the usage of the Properties class in Java. How is it used for configuration and file
handling? Give a suitable example.
9. How does Java ensure thread safety in collections? Compare synchronized
classes like Vector and Hashtable with non-synchronized ones like ArrayList
and HashMap.
2. Write a Java program to create a class called Employee with private instance
variables employee_id, employee_name, and employee_salary. Provide
public getter and setter methods to access and modify the id and name
variables, but provide a getter method for the salary variable that returns a
formatted string.
3. Write a Java program to create an abstract class BankAccount with abstract
methods deposit() and withdraw(). Create subclasses: SavingsAccount and
CurrentAccount that extend the BankAccount class and implement the respective
methods to handle deposits and withdrawals for each account type.