CS2003 Object Oriented Programming_2022_23
CS2003 Object Oriented Programming_2022_23
1 Complete the code segment to find the perimeter and area of a circle 2 CO_1 KL_2
given a value of radius.
You should use Math.PI constant in your program. If radius is zero or
less than zero then print " please enter non zero positive number ".
2 a // Import the required package(s) and/or class(es) 1 CO_1 KL_1
// default method
default void show(){
System.out.println("Default method implementation of First
interface.");
}
}
interface Second{
// Default method
default void show(){
System.out.println("Default method implementation of Second
interface.");
}
}
Page 1 of 3
// Overriding default show method
public void show(){
11 What is Polymorphism in Java? Explain its types with an example 10 CO_2 KL_1
program.
12 a Create an abstract class 'Parent' with a method 'message'. It has two 5 CO_2 KL_6
subclasses each having a method with the same name 'message' that
prints "This is first subclass" and "This is second subclass", respectively.
Call the methods 'message' by creating an object for each subclass.
b Step 1: Create a package named 'bankAccount' and make a class 5 CO_2 KL_6
'Account'.
Step 2: Declare private data members (long acc_no, name,email,
amount) to hide the data
Step 3: Apply public getter and setter method for each private variable
in the class.
Step 4: Create the instance of Account class
Step 5: Set the values through setter methods
Step 6: Get the values through getter methods
Step 7: Print the output.
13 Discuss Exception handling in detail (definition, five keyword, types of 10 CO_3 KL_1
exception with a sample program).
Page 2 of 3
14 a Develop a multithreaded program as in the previous exercise by creating 5 CO_4 KL_4
the MyThread subclass of Thread. Then create threads as objects of the
class MyClass, which is not a subclass of Thread. MyClass will
implement the runnable interface and objects of MyClass will be
executed as threads by passing them as arguments to the Thread
constructor.
b Develop a multithreaded program by creating a subclass of Thread and 5 CO_4 KL_4
then creating, initializing, and staring two Thread objects from your
class. The threads will execute concurrently and display Java is hot,
aromatic, and invigorating to the console window.
15 Write an event handling program to handle a Button event in Swing. 10 CO_5 KL_3
16 Write an event handling program to handle a Mouse event in Applet. 15 CO_5 KL_3
Page 3 of 3