Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

School of Engineering

Department of Computer Science and Engineering

CSE 204: Object Oriented Programming


End Term Lab Examination

5th COM, ISE and ECM Odd Semester 2021-2022

Programming Questions Total Marks=60

Date: 29.01.2022 Weightage: 50%

Time: 2:20pm to 5:20pm

PART-A : Max Marks=20 PART-B: Max Marks=40

Sl.No Roll Number Student’s Name Question Number


1 20191ISE0058 GUDITI SUMANTH SAI CHANDRA Q1
2 20191ISE0059 GUNDA SHASHWANTH Q2
3 20191ISE0060 GURUKIRAN E M Q3
4 20191ISE0061 H N JAISOORYA Q4
5 20191ISE0062 HANEEN HEEBA Q5
6 20191ISE0063 HARSHINI A P Q6
7 20191ISE0064 HEMANTH Q7
8 20191ISE0065 JAHNAVI S Q8
9 20191ISE0066 JAISHREE R M Q9
10 20191ISE0067 JANAGANI PRASANTHI Q10
11 20191ISE0068 K KALYAN Q11
12 20191ISE0070 K RAJESHWARI Q12
13 20191ISE0071 KAMMALA SANTHOSH KUMAR Q13
14 20191ISE0072 KANTHURI YADU VAMSI Q1
15 20191ISE0073 KAUSHIK REDDY Q2
16 20191ISE0074 KEERTHANA B V Q3
17 20191ISE0075 KETHA ANUDEEP KUMAR REDDY Q4
18 20191ISE0077 KRITHI K R Q5
19 20191ISE0078 KUKATTLA SAISINDHU Q6
20 20191ISE0080 LATHA S Q7
21 20191ISE0083 LIKHITA D Q8
22 20191ISE0084 LIPSA PRIYADARSHINI ACHARYA Q9
23 20191ISE0085 LOKNATH B N Q10
24 20191ISE0086 M CHARAN SAI Q11
25 20191ISE0087 MADHURA H C S Q12
26 20191ISE0088 MADHURYA C Q13
27 20191ISE0089 MADHUSHREE C Q1
28 20191ISE0090 MAHENDRA B Q2
29 20191ISE0091 MAHIMA S M Q3
30 20191ISE0092 MAHRUKH KHAN Q4
31 20191ISE0093 MALLIKARJUN S NANDYAL Q5
32 20191ISE0094 MANISH K G Q6
33 20191ISE0095 MANJESH D K Q7
34 20191ISE0096 MANJESH H B Q8
35 20191ISE0097 MANJUSHA S N Q9
36 20191ISE0098 MANJUSHREE S Q10
37 20191ISE0099 MANOJ N Q11
38 20191ISE0100 MANVITA M Q12
39 20191ISE0101 MEGHANA S Q13
40 20191ISE0102 MOHAMMED AFFAN HUSSAINI Q1
41 20191ISE0104 MOHAMMED ISHAQ HUSSAIN Q2
42 20191ISE0105 MOHAMMED RUHAIB Q3
43 20191ISE0106 MOHAMMED SAQUEEB Q4
44 20191ISE0107 MONICA K GOWDA Q5
45 20191ISE0108 MONIKA P M Q6
46 20191ISE0216 PARIKSHITH N Q7
47 20191ISE0217 ARAVIND RAJPUROHIT Q8
48 20191ISE0218 PUTTI NITHIN KUMAR Q9
49 20191ISE9003 BISMAY KUMAR SAHOO Q10
LIST OF QUESTIONS

Q1A) Declare an Interface Intstack with push() pop() methods. Implement this Interface in a
Fixedstack class. Create two objects of Fixedstack class & perform push(),pop operations.
(CO2, APPLICATION)

Q1B) Create a Java application to solve the producer consumer problem using Java’s inter thread
communication as follows. Get a sentence as input and extract the words from it. This array will be
the source for the Producer. The producer produce word by word and consumer must consume
that word respectively. Demonstrate the same with minimum of 10 words in the sentence. Once
completing this task, three threads named t1, t2, t3, should perform the following : t1 prints
“PRESIDENCY” for every 2 seconds, t2 should print “Welcome to PRESIDENCY UNIVERSITY”
for every 3 seconds and t3 should print “Have a Great Day” for every 5 seconds. Repeat this for 3
times and terminate the application with a message of “GOOD BYE”. (CO4, APPLICATION)
Q2A) Develop a java program to Nind the sum of all even numbers between any two numbers. The
difference between the two numbers must be at least 50 and these two numbers must be input through
command line arguments. Print the following details. i) all the even numbers ii) sum of all even
numbers. (CO1, APPLICATION)
Q2B) A Queue is a basic data structure that can be logically thought of as a linear structure. Three
operations that can be performed on a queue are: Insert operation which inserts an element into
the queue, Delete operation which removes the first element that was added to the queue and
Display operation which displays the elements in the inserted order. It follows First In First Out
(FIFO). Write a menu driven program in Java to perform the operations on the IntegerQueue.
Create custom exceptions to deal with the following situations:
a. “EmptyQueueException”, while trying to access from an empty queue.
b. “FullQueueExceptiom”, while trying to insert to a full queue.
c. “EmptyException”, while trying to display the elements of the queue.
(CO3, APPLICATION)

Q3A) Develop a java program to find the sum of Fibonacci series.Input the limit through
command line arguments. Print the following details. (CO1, APPLICATION)
i) fibonacci sequence
ii) Sum of the sequence.
Q3B) Suppose a customer open a Savings Bank Account in an Axis Bank. According to Bank
policy customer has to maintain initial/minimum bank balance of Rs.5000.
Provide functionality (methods) to display customer information, deposit and withdraw
transaction from the account.
i. If a customer withdraws more amount which makes the balance less than 5000, then the
user defined exception called “LessBalanceException” has to be thrown.
ii. If the customer tries to withdraw more than Rs.50000, then “TransactionNotAllowed”
exception has to be thrown.
Note: The data members for the customer shall be considered as name, address, mobnum, PAN,
Aadhar, balance. (CO3, APPLICATION)
4A) Develop a java program to Nind the sum of all factorial of a series. Input the limit through
command line argument. For example, if the limit is 5, then the result is 1!+2!+3!+4!+5!.
(CO1, APPLICATION)
Q4B) Develop a java application using Inheritance as per the following. Create an interface
called CashTree which demonstrate any ATM Machine. The CashTree interface has methods
like load_amount, checkBalance. These banks BOI_Bank, AXIS_Bank, FEDERAL_Bank,
implements the CashTree interface and implants the methods in the interface. The class has
speciNic attributes like atmLocation, atmCode, amount, balance. Add functionalities like
ViewBalance, loadAmount. The load amount should specify the number of Rs. 2000 notes,
Rs.500 notes, Rs. 200 notes and Rs.100. Based on the number of notes, calculate the total
amount loaded in the ATM.
Create a class userAccount, which maintains account with any of the Bank.
On withdrawal of the amount by the users, the bank wanted to know the amount available
in the ATM on a daily basis. Write a method to know the balance in the particular banks with
the details of atmLocation, atmCode, and the balance. If the balance is less than one lakh,
advice the authorities to load amount again.

Complete the above scenario with Menu driven options. (CO3, APPLICATION)
Q5A) Develop a program to reverse the given array without using an another array. Input the
maximum size of the array through command line arguments. (CO1, APPLICATION)

Q5B) Searching and sorting are the often used parts in any program. Create two Java packages
for searching and sorting.
a. Implement some basic searching and sorting methods in the packages.
b. Search for a particular student in a student list of CSE department. sort the
elements before performing the binary search. Use methods defined in the
packages. (Use sequential threads)
c. Sort same student list concurrently using different sorting methods available in
the packages. (use Concurrent threads) (CO3,CO4, APPLICATION)

Q6A) Develop a java program to remove the duplicate elements from the array. The duplicate
elements found in array1 should be moved to another array. Finally display both the arrays using
advanced for loop. (CO2, APPLICATION)
Q6B) Design and develop a program to spawn two threads “PALIN” and “PRIME”. PALIN
thread has to display the palindrome of a String from a given array of 10 Strings. PRIME thread
has to display all the prime numbers within 100. Display the list of palindromes. Display the list
of PrimeNumbers. Check the existence of threads using isAlive method. Make “PALIN” thread to
wait for some time till other threads completes its task. Use sleep method so that the thread will
wait one second while printing the array elements. Use advanced for loop to print the elements.
Handle all the appropriate exception, while reading the input from the user and while reading the
elements in the array. (CO4, APPLICATION)

Q7A) Develop a java program to implement the following. (CO1, APPLICATION)


4
5 4 5
6 5 4 5 6

Q7B) Assume that a bank offers different types of user accounts like saving and loan account for
its customers. For all customers basic details are common like name, address, phone, PAN and
Aadhar no., but the way this accounts operates is different. Some account pays interest like SB
A/C, some collect interest for the credit given. Demonstrate how above mentioned requirements
can be developed in Java program.
a.Identify various classes to implement this scenario
b.Specify how to store common details of the customers and separate different
functionality of the accounts.
c.Display the details of the customer with the type of account and its details.
d. Calculate ROI for SB Account or Loan Interest for at least 2 users.
(CO2, APPLICATION)

Q8A) Override area() method of Figure class to find area of a rectangle and area of a triangle
using run-time polymorphism concept. Figure class has two fields; a parameterized constructor
& an area() function. (CO2, APPLICATION)

Q8B) Consider a scenario of myself owning a car and a bike, which need fuel to run. The
maximum speed at which my car can run is 150 Km/Hr and bike is 100 Km/Hr. write a java
program to define an abstract class which contain methods for printing the status of fuel (EMPTY,
HALF or FULL) in the vehicle and top speed of it. Vehicles fuel status and top speed is initialized
at the time of object creation.

a. Identify the abstract class and normal class to implement above scenario.
b. Check whether constructors can be used in the abstract class.
c. Identify abstract and non-abstract methods in a abstract class.
d. Demonstrate how to pass values from derived class constructor to base class constructor.
e. Display the attributes of the car and a bike using abstract method.

(CO1,CO2, APPLICATION)
Q9A) Define an exception called “NoMatchException” that is thrown when a string is not equal
to “PRESIDENCY”. Develop a JAVA Program that uses this exception. (CO3,
APPLICATION)

Q9B) Consider a scenario in which I like to go on a business tour from Chennai to Delhi for
attending some board meeting at Indore on the way. The business tour is finalized by my
Secretary and put into an interface. The interface tells from where to where to go but not how to
go – by plane, by bus or by train. The interface "TourPlan" is given with dates to a travel agent to
book tickets. Now the travel agent writes a Java class implementing the interface and overriding
all methods of interface. He knows very well, if any abstract method is not overridden, I cannot
go to Delhi. It is a must to override or implement with the mode of travel. (hint: use INTERFACE)
a. Identify abstract methods in the interface.
b. Calculate the travel expenses for a trip. (CO3, APPLICATION)

Q10A) Develop a java program to input a two digit number through command line arguments and
find the octal of the number. Reverse the octal digits and convert to decimal number. Print the
following details : i) Octal format of the given number ii) Reversed Octal number iii)Decimal of
the reversed octal number..
For example, if input number is 45, then the octal is 55: , Reversed octal is 55, and the decimal
of reversed octal is : 45 (CO1, APPLICATION)

Q10B) Consider a scenario similar to Producer/Consumer problem in day to day life where son
is studying engineering in other state, for his expenditure father will be depositing some money
to his account every month. Father will wait until his son notifies him to deposit money else son
will wait until he spends available amount in the account. In this example depositing (put) and
withdrawing (get) is considered as synchronized method executed by father and son on a shared
account.(Hint: INTER THREAD COMMUNICATION) (CO4, APPLICATION)

Q11A) Develop a java program to find the number of occurrences of every element in
an array. (CO1, APPLICATION)

Q11B) Develop a menu driven application to maintain the department details of a School. Your
application must contain the following functionalities along with the use of method overriding,
and super keyword. Consider the example of school of Computer Science with three departments
CSE, CST and ISE. For each department maintain the following details : deptName, hodName,
noOfFaculty, noOfStudents. i) Input these details form the user. ii) For each students maintain their
CGPA. iii) If the CGPA is less than 7.0, the student is not eligible for placement. For each
department calculate the percentage of students eligible for placement. iv) There should be one
faculty per 15 students in the department. For each department Nind the student faculty ratio.v)
Display the Department list with all details in a proper and neat format.(CO1, APPLICATION)
Q12A) Develop a java program to generate the following pattern. (CO1, APPLICATION)

X
X Y
X Y Z
X Y
Z
Q12B) You recently read a blog post about the merits of using short sentences while writing.
The article inspires you to write a program to work with the Collections. When the exercise
below is run, it will ask input a sentence. i) Split this sentence into separate words and store in
wordsList. ii) Iterate through the wordList and print the length of each words. iii) Create a
collection called uniqueWords that will store only unique words from this sentence. iv) Use a
collection to sort the words in alphabetical order. v) Add a LinkedList so that you can add the last
word in the wordList to Nirst. vi) Iterate through the linked list and display all the words again.

(CO5, APPLICATION)

Q13A) Develop a java program to input a two digit number through command line arguments and
find the binay of the number. Reverse the binary digits and convert to decimal number. Print the
following details : i) Binay format of the given number ii) Reversed Binay number iii)Decimal of
the reversed binay number..
For example, if input number is 12, then the binay is 1100: , Reversed binary is 0011 , and the
decimal of reversed binay is : 3 (CO1, APPLICATION)

Q13B) Implement a java program to perform the operations on Matrix using multithreading.
Read the input for 3 X 3 matrix and perform matrix addition, transpose of matrix, matrix
multiplication, with three different threads. While displaying the matrix, make the thread sleep
for 1 second. Handle appropriate exception while using the arrays. (CO2, CO4,
APPLICATION)

You might also like