0% found this document useful (0 votes)
2 views9 pages

23CB1504 Java Programming QB

The document outlines a course on Java Programming offered by the Computer Science and Business Systems department, detailing course outcomes, unit topics, and assessment components. It covers fundamental concepts such as Java basics, object-oriented programming, exception handling, and multithreading, with specific learning objectives aligned to Bloom's taxonomy. The document includes a question bank with various types of questions categorized by difficulty and marks allocation for assessments.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views9 pages

23CB1504 Java Programming QB

The document outlines a course on Java Programming offered by the Computer Science and Business Systems department, detailing course outcomes, unit topics, and assessment components. It covers fundamental concepts such as Java basics, object-oriented programming, exception handling, and multithreading, with specific learning objectives aligned to Bloom's taxonomy. The document includes a question bank with various types of questions categorized by difficulty and marks allocation for assessments.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

QUESTION BANK

Details of the Course


Name of the Department : Computer Science and Business Systems
Name of the Course : Java Programming
Course Code : 23CB1504
Regulation : 2023
Semester : VI
Common To Programme(s) :
Blooms Level: Blooms Level 1 & 2 is Lower Order (LO) Cognitive type, Blooms Level 3 & 4 is Intermediate Order Cognitive
Type (IO) and Blooms Level 5 & 6 is Higher Order (HO) cognitive type.

COURSE OUTCOMES:
CO1: Demonstrate an understanding of Java programming basics, including its features, syntax,
and structure, and implement programs using control structures and operators.
CO2: Object-oriented programming concepts like encapsulation, inheritance, polymorphism, and
abstraction to solve real-world problems in Java.
CO3: Handle runtime errors effectively using exception handling mechanisms and develop
concurrent applications using multithreading concepts.
CO4: Implement advanced Java features such as file handling, serialization, deserialization, and
collections to manage and process data efficiently.
CO5: Create interactive GUI-based applications and implement networking solutions using Java
Swing, AWT, sockets, and HTTP communication.
CO6: Utilize Java 8+ features like lambda expressions, the Streams API, and explore the basics
of modern frameworks to develop scalable and robust applications
Bloom’s Level: BL1 - Remembering, BL2 - Understanding, BL3 - Applying, BL4 - Analyzing, BL5 – Evaluating, BL6 - Creating.

UNIT-I INTRODUCTION TO JAVA PROGRAMMING


Bloom’s Course Marks
PART – A (2 Marks)
Level Outcome Allotted
1. What is Java? [BL1] [CO1] [2]
2. List the main features of Java. [BL1] [CO1] [2]
3. What is the primary purpose of JVM? [BL1] [CO1] [2]
4. Differentiate between JDK and JRE. [BL2] [CO1] [2]
5. Why Java is called platform-independent? [BL2] [CO1] [2]
6. Write a simple Java class named Hello with a main method that [BL3] [CO1] [2]
prints "Hello".

Course Instructor Course Coordinator Head of the Department


Name & Designation Name & Designation
7. What is method overloading in Java? [BL2] [CO1] [2]
8. How do you declare a constant integer variable MAX with value [BL1] [CO1] [2]
100?
9. Apply the ternary operator in the following code and find the [BL3] [CO1] [2]
output:
int x = 10;
int y = 20;
[Link]((x > y) ? x : y);
10. Write the syntax of an if-else statement in Java. [BL1] [CO1] [2]

PART- B (13 Marks)


1. Explain the role of the Java Virtual Machine (JVM) in Java [BL2] [CO1] [13]
program execution.
2. Describe JVM, JRE, and JDK, and explain how each contributes [BL2] [CO1] [13]
to the execution of a Java program.
3. Write two overloaded methods named multiply, one that [BL3] [CO1] [13]
multiplies two integers and another that multiplies two doubles
4. For a banking enterprise, design a class Account with data [BL3] [CO1] [13]
members like account number, account holder name, and
balance. Include methods for depositing money, withdrawing
money (check for sufficient balance), and displaying the account
details. Write a main method to demonstrate creating an account
and performing transactions.
5. Summarize any five key features of Java and explain their [BL2] [CO1] [13]
significance in Java programming.
6. Explain the differences between if-else, switch-case, and loop [BL2] [CO1] [13]
control statements in Java with syntax and examples.
7. Classify the different types of operators in Java and illustrate [BL2] [CO1] [13]
each type with a suitable example.
8. Create a Java program to demonstrate method overloading. Write [BL3] [CO1] [13]
a class Calculator with methods to add two integers, add three
integers, and add two double values. Show how the appropriate
method is called based on the arguments passed.
9. Write a Java program to implement a simple calculator using [ BL3] [CO1] [13]
switch-case for addition, subtraction, multiplication, and
division.
10. Demonstrate method overloading in Java by creating methods to [BL3] [CO1] [13]
calculate the area of a square, rectangle, and circle.
PART- C (15 Marks)
1. Evaluate which loop (for, while, do-while) is best suited for [BL5] [CO1] [15]
executing a block of code at least once and justify your choice.
2. Analyze the concept of constructor overloading in a class with [BL4] [CO1] [15]
multiple constructors and discuss how it enhances flexibility
during object instantiation.
3. Create a scenario where multiple operations need to be [BL5] [CO1] [15]
performed using user input, suggest the most suitable control
structure and justify your answer.
4. Evaluate the statement "Java is both a compiled and an [BL5] [CO1] [15]
interpreted language" by explaining the roles of JDK, JRE, and
JVM. Justify why Java cannot execute without JVM.

Course Instructor Course Coordinator Head of the Department


Name & Designation Name & Designation
5. Create a complete Java program with a class Student containing a [BL6] [CO1] [15]
parameterized constructor, a copy constructor, and an overloaded
method display() (one version without parameters, another with a
grade parameter). In the main method, instantiate two objects
using both constructors and invoke both versions
of display() using a loop.

UNIT-II OBJECT - ORIENTED PROGRAMMING IN JAVA


Bloom’s Course Marks
PART – A (2 Marks)
Level Outcome Allotted
1. What is encapsulation in Java? [BL1] [CO2] [2]
2. Define inheritance. [BL1] [CO2] [2]
3. Compare compile-time and runtime polymorphism? [BL2] [CO2] [2]
4. Describe the concept of abstraction in Java and provide a simple [BL2] [CO2] [2]
example.
5. What is the purpose of final keyword in Java? [BL1] [CO2] [2]
6. Why is hybrid inheritance not supported directly in Java? [BL2] [CO2] [2]
7. Write a simple example of multilevel inheritance in Java. [BL3] [CO2] [2]
8. Describe how method overriding works in Object-Oriented [BL2] [CO2] [2]
Programming.
9. Differentiate between method overloading and overriding. [BL2] [CO2] [2]
10. Write an example showing the use of the super keyword to call a [BL3] [CO2] [2]
parent method.
PART- B (13 Marks)
1. Define and explain the four core principles of Object-Oriented [BL1] [CO2] [13]
Programming (OOP): Encapsulation, Inheritance, Polymorphism,
and Abstraction.
2. Differentiate between compile-time and runtime polymorphism [BL2] [CO2] [13]
with suitable code examples.
3. Write a Java program to demonstrate multilevel inheritance. [BL3] [CO2] [13]
Create a class Vehicle with a method start(). Derive a class Car
from Vehicle with a method drive(). Then derive a class
ElectricCar from Car with a method charge(). Instantiate an
object of ElectricCar and demonstrate calling all three methods.
4. Write a Java program to demonstrate method overriding using [BL3] [CO2] [13]
the super keyword. Explain how method overriding helps in
runtime polymorphism.
5. Create an interface Shape with an abstract method perimeter(). [BL3] [CO2] [13]
Implement two classes Circle and Rectangle that implement the
Shape interface and provide their own implementations of the
perimeter() method. Write a main class to instantiate objects of
both classes and display their areas. Explain how interfaces
support multiple inheritance in Java.
6. Analyze the role of the final keyword in inheritance and [BL4] [CO2] [13]
polymorphism. What are the implications of using final on
methods and classes?

Course Instructor Course Coordinator Head of the Department


Name & Designation Name & Designation
7. Compare abstract classes and interfaces in Java in terms of [BL4] [CO2] [13]
design, performance, and use cases. Include at least one real-
world scenario where each is preferred.
8. Explain in detail the concept of abstract classes and abstract [BL1] [CO2] [13]
methods in Java. Give suitable examples.
9. Describe how Java implements multiple inheritance using [BL2] [CO2] [13]
interfaces. Explain with a program.
10. Write a Java program using an abstract class Vehicle with [BL3] [CO2] [13]
abstract method move() and create subclasses Car and Bike that
implement the method. Demonstrate polymorphism using the
program.
PART- C (15 Marks)
1. Develop a Java application that demonstrates multiple [BL5] [CO2] [15]
inheritance using interfaces. Create interfaces Scanner and
Printer with some common and unique methods. Then create a
class MultiFunctionDevice implementing both interfaces. Include
method overriding and use of default/static methods in interfaces.
Critically evaluate how Java interfaces help avoid the diamond
problem and facilitate multiple inheritance.
2. Construct a software module using OOP principles [BL6] [CO2] [15]
(Encapsulation, Abstraction, Inheritance, Polymorphism) for a
school management system. Justify how each principle is
applied.
3. Evaluate how polymorphism improves code extensibility and [BL5] [CO2] [15]
maintainability. Provide examples and suggest scenarios where
using polymorphism might not be ideal.
4. Evaluate why Java does not support multiple inheritance through [BL5] [CO2] [15]
classes but supports it through interfaces. Justify your answer by
comparing the diamond problem in hybrid inheritance with the
solution provided by interfaces. Also, critique the statement:
"Abstract classes are better than interfaces when code reusability
is the primary goal."
5. Create a complete Java program to demonstrate runtime [BL6] [CO2] [15]
polymorphism. Design an abstract class Shape with an abstract
method area(). Create three subclasses Circle, Rectangle,
and Triangle that implement area(). In the main method, create
an array of Shape references, store objects of each subclass, and
invoke area() for all using a loop. Use the super keyword
appropriately in at least one subclass constructor.

Course Instructor Course Coordinator Head of the Department


Name & Designation Name & Designation
UNIT-III EXCEPTION HANDLING AND MULTITHREADING
Bloom’s Course Marks
PART – A (2 Marks)
Level Outcome Allotted
1. What is an exception in Java? [BL1] [CO3] [2]
2. Enumerate the types of exceptions in Java. [BL1] [CO3] [2]
3. What is the purpose of the try block in Java? [BL1] [CO3] [2]
4. What does the finally block do? [BL1] [CO3] [2]
5. What keyword is used to manually throw an exception? [BL1] [CO3] [2]
6. What is the use of the throws keyword? [BL1] [CO3] [2]
7. What is a custom exception? [BL1] [CO3] [2]
8. What is a thread in Java? [BL1] [CO3] [2]
9. What method starts a thread? [BL1] [CO3] [2]
10. What is thread synchronization, and what is its purpose? [BL2] [CO3] [2]

PART- B (13 Marks)


1. Define exception handling in Java. List and explain the five key [BL2] [CO3] [13]
keywords used: try, catch, finally, throw, and throws with syntax
and examples.
2. Explain the different types of exceptions in Java: checked and [BL2] [CO3] [13]
unchecked exceptions. Support your answer with class hierarchy
and examples.
3. Write short notes on threads. Write a Java program that creates [BL3] [CO3] [13]
two threads. Each thread should print numbers from 1 to 10 with
a delay. Demonstrate how both threads run concurrently.
4. Create a custom exception class called AgeException. Write a [BL3] [CO3] [13]
Java program that prompts the user to input the age. If the age is
less than 18, throw the AgeException. Handle this exception and
display a meaningful message to the user.
5. Create a Java program by implementing the Runnable interface [BL6] [CO3] [13]
to start multiple threads. Show the difference between extending
Thread and implementing Runnable.
6. Analyze the use of synchronized keyword in Java. Write a [BL4] [CO3] [13]
program to demonstrate synchronization and explain how it
prevents race conditions.
7. Compare and contrast the use of try-catch-finally with throws in [BL4] [CO3] [13]
exception handling. When should each approach be used?
8. Differentiate between extending the Thread class and [BL2] [CO3] [13]
implementing the Runnable interface. Provide examples for both
approaches.
9. Write a Java program to demonstrate synchronization using a [BL3] [CO3] [13]
shared resource. Explain how synchronization helps in
preventing race conditions.
10. Analyze the role of thread priorities and inter-thread [BL5] [CO3] [13]
communication in Java. Write a program to demonstrate wait(),
notify(), and notifyAll() methods.

Course Instructor Course Coordinator Head of the Department


Name & Designation Name & Designation
PART- C (15 Marks)
1. Design a multithreaded application that simulates a ticket [BL5] [CO3] [15]
booking system where multiple threads access a shared resource.
Use synchronization to avoid data inconsistency.
2. Evaluate the importance of exception handling in real-time [BL5] [CO3] [15]
applications like banking or e-commerce. Support your answer
with example scenarios.
3. Construct a Java program that uses inter-thread communication [BL6] [CO3] [15]
using wait(), notify(), and notifyAll(). Evaluate its use in
producer-consumer problems.
4. Evaluate the impact of synchronization in multithreading by [BL5] [CO3] [15]
comparing a scenario where two threads access a shared bank
account balance with and without synchronized methods. Justify
why the finally block is critical in exception handling even when
a catch block is present. Also, critique the statement: "Checked
exceptions should always be handled using try-catch rather than
using the throws keyword."
5. Create a complete Java program with two threads simulating a [BL6] [CO3] [15]
producer-consumer scenario using inter-thread communication
(wait(), notify()). The producer thread generates numbers from 1
to 5 and adds them to a shared queue (maximum size 1). The
consumer thread removes and displays each number. Use proper
synchronization to avoid inconsistency. Also, create a custom
exception called QueueFullException that is thrown if an attempt
is made to add to a full queue.

UNIT-IV ADVANCED JAVA CONCEPTS


Bloom’s Course Marks
PART – A (2 Marks)
Level Outcome Allotted
1. What is the difference between byte stream and character stream [BL1] [CO4] [2]
in Java?
2. Name any two classes used for file handling in Java. [BL1] [CO4] [2]
3. What is serialization in Java? [BL1] [CO4] [2]
4. What is the purpose of the transient keyword in serialization? [BL1] [CO4] [2]
5. List any two interfaces in the Java Collections Framework. [BL1] [CO4] [2]
6. What is the purpose of an Iterator in Java? [BL2] [CO4] [2]
7. What is the use of Generics in Java collections? [BL1] [CO4] [2]
8. Name any two implementations of the List interface. [BL1] [CO4] [2]
9. What is the use of the serializable interface. [BL2] [CO4] [2]
10. What is a PreparedStatement in JDBC? [BL1] [CO4] [2]

PART- B (13 Marks)

Course Instructor Course Coordinator Head of the Department


Name & Designation Name & Designation
1. Define and describe the differences between Byte Streams and [BL2] [CO4] [13]
Character Streams in Java I/O. Provide examples of commonly
used classes for each.
2. Explain serialization and deserialization in Java with suitable [BL2] [CO4] [13]
examples. Discuss how the transient keyword affects this
process.
3. Describe the interfaces List, Set, Map, and Queue in the Java [BL2] [CO4] [13]
Collections Framework. Provide at least one implementation
example for each.
4. Write a Java program that reads text from a file, converts it to [BL3] [CO4] [13]
uppercase, and writes it to a new file using character streams.
5. Develop a Java program using ArrayList and Iterator to store and [BL3] [CO4] [13]
display a list of student names. Include logic to remove names
starting with a specific letter.
6. Analyze the differences between HashMap and TreeMap in Java. [BL4] [CO4] [13]
Write a program to demonstrate how insertion order and sorting
are handled.
7. Compare and contrast Generics and non-generics in Java [BL4] [CO4] [13]
collections. How do Generics improve type safety and reduce
runtime errors?
8. Analyze the role of Generics and Iterators in Java Collections. [BL4] [CO4] [13]
Demonstrate with examples how Generics provide type safety
and how Iterators help in safe traversal.
9. Explain the role of JDBC in Java. Write a Java program that [BL3] [CO4] [13]
connects to a database, executes a SELECT query using a
PreparedStatement, retrieves the results using ResultSet, and
displays them.
10. Design and implement a Java program to manage a simple [BL3] [CO4] [13]
student attendance system using file handling and collections.
The program should read product data from a file, store it in an
appropriate collection, and allow the user to search attendance by
student name.
PART- C (15 Marks)
1. Design a mini application using JDBC that connects to a MySQL [BL5] [CO4] [15]
database, inserts a record using PreparedStatement, and displays
records using ResultSet.
2. Develop a Java program that uses the Collections Framework to [BL5] [CO4] [15]
maintain and operate an inventory management system. Use
appropriate collection types for storing different product
attributes. Implement functionality to add, remove, and search
products. Use iterators and generics to process the collections.
Justify your choice of collections for different parts of the
system.
3. Create a Java program to read data from a text file and insert it [BL6] [CO4] [15]
into a database table using JDBC. Discuss challenges and how to
handle exceptions.
4. Evaluate why serialization is necessary for sending objects over a [BL5] [CO4] [15]
network or storing them in a file. Justify your answer by
comparing the use of Serializable interface with saving each
object attribute individually to a text file. Also, critique the
statement: "ArrayList is always better than HashSet because it

Course Instructor Course Coordinator Head of the Department


Name & Designation Name & Designation
maintains insertion order and allows duplicates."
5. Create a complete Java program that performs the following [BL6] [CO4] [15]
operations:
1. Create an ArrayList<String> to store names of 5 cities.
2. Use a for-each loop to display all city names.
3. Write all city names from the ArrayList into a text file
named [Link] using FileWriter.
4. Read and display the contents of [Link] from the file
using FileReader.
5. Handle all possible exceptions using try-catch-finally

UNIT-V JAVA ADVANCED FEATURES


Bloom’s Course Marks
PART – A (2 Marks)
Level Outcome Allotted
1. What is the full form of AWT? [BL1] [CO5] [2]
2. What is the difference between AWT and Swing in Java? [BL2] [CO5] [2]
3. What is a container in Swing? [BL1] [CO5] [2]
4. What is the difference between JFrame and JPanel? [BL1] [CO5] [2]
5. What is a socket in Java networking? [BL1] [CO5] [2]
6. Which package provides networking support in Java? [BL1] [CO5] [2]
7. What is a lambda expression in Java 8? [BL1] [CO6] [2]
8. What is a functional interface? [BL1] [CO5] [2]
9. Name two built-in functional interfaces in Java. [BL1] [CO5] [2]
10. What is the use of the Stream API? [BL1] [CO6] [2]

PART- B (13 Marks)


1. Explain the differences between AWT and Swing. Write a [BL2] [CO5] [13]
program to create a simple login form using Swing components.
2. Explain the Java event delegation model with examples. Describe [BL2] [CO5] [13]
the roles of event source, listener, and event object.
3. Discuss the differences between various layout managers in Java [BL2] [CO5] [13]
(FlowLayout, BorderLayout, GridLayout). Support your answer
with layout examples.
4. Write a Java Swing program to create a login form with [BL3] [CO5] [13]
username and password fields, a login button, and validation on
click.
5. Create a client-server application using Socket and ServerSocket [BL3] [CO5] [13]
classes in Java that sends a greeting message from the server to
the client.
6. Explain the difference between default and static methods in [BL2] [CO6] [13]
interfaces introduced in Java 8. Write an interface with both
types of methods and a class that implements this interface.
7. Analyze the use of Streams API in Java 8. Demonstrate filtering, [BL4] [CO6] [13]
mapping, and reducing a list of integers using streams.

Course Instructor Course Coordinator Head of the Department


Name & Designation Name & Designation
8. Develop a simple Spring application using Spring Core to [BL3] [CO5] [13]
demonstrate Dependency Injection using annotations. Explain
how Spring simplifies the development of loosely coupled
applications.
9. Write a JavaFX application to create a basic GUI for a login form [BL3] [CO6] [13]
with username and password fields. Explain how JavaFX handles
UI components and event-driven programming.
10. Compare and analyze the behavior of TCP and UDP [BL4] [CO5] [13]
communication in Java. Highlight their differences with
examples of when each should be used.
PART- C (15 Marks)
1. Create a Java Swing application that uses layout managers to [BL5] [CO5] [15]
create a form-based application with proper component
alignment and event handling.
2. Evaluate the advantages of lambda expressions and functional [BL5] [CO6] [15]
programming features in Java 8 over traditional anonymous
classes.
3. Evaluate the architectural overview of Spring and Hibernate [BL5] [CO5] [15]
frameworks. Compare their roles and explain when and why you
would use them in real-world applications.
4. Evaluate why lambda expressions were introduced in Java 8 [BL5] [CO5] [15]
despite Java already having anonymous inner classes. Justify
your answer by comparing the readability, code length, and
performance of both approaches.
5. Create a complete Java program that demonstrates the following: [BL6] [CO6] [15]
1. Create a Functional Interface named Calculator with a
single abstract method int operate(int a, int b).
2. Implement this interface using lambda expressions for
three operations: addition, subtraction, and multiplication.
3. Create an ArrayList<Integer> with 5 integers.
4. Use the Streams API to:
o Filter numbers greater than 10
o Square each remaining number
o Display the result
5. Handle the result using a simple for-each loop.

Course Instructor Course Coordinator Head of the Department


Name & Designation Name & Designation

You might also like