0% found this document useful (0 votes)
34 views3 pages

Uta028 Est 24

Uploaded by

vashisht.atharv5
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)
34 views3 pages

Uta028 Est 24

Uploaded by

vashisht.atharv5
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
You are on page 1/ 3

Thapar Institute of Engineering and Technology, Patiala

Computer Science and Engineering Department

Course Name: Object Oriented Programming (Java) Course Code: UTA028


Coordinator: Karun Verma End Semester Exam
Time: 3 Hrs Maximum Marks: 40
Note: 1. Attempt any Five questions.
2. Start answering each question on a separate page. Attempt all subparts of the
question in continuation.
Q Question Marks CO BL
Q1. a. What are threads? 2 CO5 L2
b. What are different ways a thread can be created? Explain with an 3 CO5 L2
example.
c. Write a program in Java that creates two thread and starts them 3 CO5 L4
simultaneously where one of the threads prints Odd numbers while
the other thread prints the Even numbers
Q2 a. What does the statement “Java is platform independent” means and 2 CO1 L3
does Java supports multiple inheritance? Justify with examples
b. What is difference between final and finally?
c. Explain with example the difference between throw and throws. 2 CO1 L2
d. What is an abstract class? Can an abstract method be declared as 2 CO5 L3
private? Justify
(1+1) CO2 L3
Q3 a. How do interfaces facilitate multiple inheritance in Java, and what 4 CO3 L3
are the key advantages they offer in terms of code organization and
flexibility?
b. Design an interface named 'Shape' with methods to calculate area 4 CO3 L4
and perimeter. Implement this interface in classes for different
geometric shapes like circle, square, and triangle. Then, write a Java
program to create instances of these shapes, calculate their areas and
perimeters, and display the results.

Q4 a. Create a Java program to model a library system using inheritance. 4 CO3 L4


Define a base class 'Item' with attributes such as 'title', 'author', and
'itemID'. Then, derive subclasses 'Book' and 'DVD' from 'Item',
each with their own unique attributes and methods. Finally,

1 of 25
demonstrate inheritance by creating instances of both subclasses and
accessing their attributes and methods.
b. Explain the concept of ActionListener in Java Swing and how it 4 CO4 L4
facilitates event handling in graphical user interfaces. Provide a code
example demonstrating the implementation of an ActionListener for
a JButton in a simple GUI application, explaining each step involved
in handling button click events.
Q5 a. Differentiate between Overloading and Overriding. 3 CO2 L3
b. Create a Java program that demonstrates method overloading by 5 CO2 L4
defining multiple versions of a method named 'calculateArea'. Each
version should accept different parameters, such as radius for
calculating the area of a circle, length and width for calculating the
area of a rectangle, and base and height for calculating the area of a
triangle. Test the program by calling each version of the
'calculateArea' method with appropriate parameters.
Q6 a. How does exception handling work in Java, and what are the key 2 CO4 L3
principles to follow when designing robust exception handling code?
b. Discuss the differences between public, private, protected, and
default access modifiers in Java, highlighting when and why you 4 CO1 L4
would use each. Then, provide a scenario-based question where a
class with different access modifiers is utilized, and explain the
expected outcomes based on the access restrictions imposed by those
modifiers.
c. Given the following Java code snippet, predict the output and
identify any exceptions that may occur during its execution: 2 CO4 L4
public class ExceptionExample{
public static void main(String[] args){
try {
int result = divide(10, 0);
System.out.println("Result: " + result);
} catch (ArithmeticException e) {
System.out.println("Error: Division by
zero");
} finally {
System.out.println("Finally block
executed");

2 of 25
}
}
public static int divide(int dividend, int divisor)
{
return dividend / divisor;
}
}

Bloom Level Wise Marks


Distribution

15%
L2

52% L3
33% L4

Course Outcome wise Marks


Distribution

CO1 CO2 CO3 CO4 CO5

3 of 25

You might also like