Professional Documents
Culture Documents
ISEPBTech539532kObjkPr - OOP END Term Answers - On - CSE 204 - OOP END TERM 5ISE2 - 29JAN2022
ISEPBTech539532kObjkPr - OOP END Term Answers - On - CSE 204 - OOP END TERM 5ISE2 - 29JAN2022
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)
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)