Java Question Bank
Java Question Bank
UNIT I
INTRODUCTION TO OOP AND JAVA FUNDAMENTALS
CO’s Bloom’s
Q.No Questions
Level
PART A
1. Define object-oriented programming (OOP). CO1 K1
2. Describe the structure of a Java source file. CO1 K3
3. Name any two Java access specifiers. CO1 K1
4. What is the role of the Java Virtual Machine (JVM)? CO1 K1
5. What is the function of the main method in a Java program? CO1 K1
6. Differentiate between static and non-static members in Java CO1 K2
7 Enlist the various data types in Java CO1 K2
8. Give any four examples of JavaDoc Comments CO1 K1
9. Mention the various properties of constructors in Java CO1 K2
10. How a java program is compiled and executed CO1 K1
11. Write a Java program to check whether a given number is Prime or Not CO1 K3
12. Write a Java program to generate Fibonacci Series CO1 K3
13. Identify the various components of a package in Java CO1 K1
14. What is a package in Java? CO1 K1
15. How will you define an 2 D array in Java. CO1 K2
CO’s Bloom’s
Q.No Questions
Level
PART B
Explain how arrays are declared, initialized, and accessed in Java. Write a
1. K3
program to find the maximum value in an integer array. CO1
Brief about the significance of JavaDoc comments? Write a sample Java
2. K3
class with properly documented JavaDoc comments CO1
Enlist and describe the various salient features of Java Language in detail
3. K3
with suitable examples CO1
Develop a Java program using constructors and suitable methods for
4. K3
employee management system CO1
5. Write a Java program to perform matrix addition and multiplication CO1 K3
6. Enlist the various features of OOPs and explain them in detail CO1 K3
7 Develop a Java program using packages for banking applications CO1 K5
Write the step by step procedure for creating a package with a suitable
8. K3
example CO1
CO’s Bloom’s
Q.No Questions
Level
PART C
Given an array of integers, rearrange the array in such a way that the first
1. element is first maximum and second element is first minimum. C01 K5
Eg.) Input : {1, 2, 3, 4, 5, 6, 7} Output : {7, 1, 6, 2, 5, 3, 4}
Given an array as input, The condition is if the number is repeated you C01
must add thenumber and put the next index value to 0. If the number is 0
2. K5
print it at the last
Egarr[]={0,2,2,2,0,6,6,0,8}Output : { 4 ,2 ,12,8,0,0,0,0,0}
UNIT II
INHERITANCE AND INTERFACES
CO’s Bloom’s
Q.No Questions
Level
PART A
1. Enlist the various types of inheritance schemes supported in Java CO2 K1
2. Define an abstract class CO2 K2
3. Diffentiate classes from interfaces CO2 K2
4. Can an interface extend another interface? If so Give example CO2 K2
5. What is object cloning in Java? CO2 K2
6. Give an example of inner classes in Java CO2 K2
7. Write a simple program using inner classes in Java CO2 K2
8. Write any four string buffer methods CO2 K1
9. Compare String and String Buffer classes CO2 K2
Write a Java program to check whether the given string is palindrome or
10. CO2 K2
not
11. List the advantages of using String Buffer class. CO2 K1
12. Enlist the three contexts of using final keyword. CO2 K2
13. How will you avoid method overriding in Java ? CO2 K2
14. Give the usage of super keyword. CO2 K2
15. Write the syntax of single inheritance in Java CO2 K1
CO’s Bloom’s
Q.No Questions
Level
PART B
Explain the differences between single inheritance and multilevel
1. CO2 K3
inheritance. Provide examples of how they can be implemented in Java.
How does the super keyword work in Java? Illustrate its use with an CO2
2. example where a subclass calls the constructor and methods of its K3
superclass.
What is the purpose of abstract classes and methods in Java? How do they
3. differ from interfaces? Provide examples demonstrating their CO2 K3
implementation.
What is the role of the final keyword when applied to methods and CO2
4. K3
classes? What are the benefits and limitations?
How are interfaces defined and implemented in Java? What are the key
5. CO2 K4
differences between extending a class and implementing an interface?
Explain the concept of object cloning in Java. How is the clone() CO2
6. method implemented? Provide an example demonstrating deep and K3
shallow cloning.
7. Write and explain any 10 Sringbuffer methods in Java CO2 K5
8. Write and explain any 10 Sring handling functions in Java CO2 K5
CO’s Bloom’s
Q.No Questions
Level
PART C
Write a Java program that demonstrates inheritance and the use of abstract
classes:
Define an abstract class Shape with an abstract method
1. calculateArea().Create subclasses Circle, Rectangle, and Triangle, each CO2 K5
implementing the calculateArea() method.Include constructors and
protected variables for common properties like radius or side.
Use a driver class to create objects of each subclass and display their area.
Write a Java program that involves interfaces and object cloning: CO2
Define an interface Printable with a method printDetails().
Create a class Book that implements the interface and includes properties
2. like title, author, and price. K6
Add a method to perform deep cloning of the Book object.
Demonstrate object cloning by creating and modifying a cloned Book
object without affecting the original.
UNIT III
EXCEPTION HANDLING AND I/O
CO’s Bloom’s
Q.No Questions
Level
PART A
1. What is an exception? CO3 K1
2. Name two common exceptions in Java CO3 K2
3. What is the base class for exceptions in Java? CO3 K2
4. What is the purpose of the try block? CO3 K2
5. What is the purpose of the catch block? CO3 K2
6. What is a finally block? CO3 K2
7. Define the term "throwing an exception." CO3 K2
8. How do you catch an exception in Java? CO3 K1
9. How can you create your own exception class? CO3 K2
10. Differentiate between checked and unchecked exceptions. CO3 K2
11. What is the purpose of the throw keyword? CO3 K1
12. What is a byte stream? CO3 K2
13. What is a character stream? CO3 K2
14. Name two classes used for reading files in Java. CO3 K2
15. What is the difference between FileReader and FileInputStream? CO3 K1
CO’s Bloom’s
Q.No Questions
Level
PART B
Discuss the hierarchy of exception classes in Java. Provide examples of
1. common exceptions and their usage. CO3 K3
CO’s Bloom’s
Q.No Questions
Level
PART C
Design a Java program that performs the following: Takes two numbers as
input from the user.