Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
6 views

oops_problems(JAVA)

Uploaded by

syndicatework21
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

oops_problems(JAVA)

Uploaded by

syndicatework21
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

C OMPUTER S CIENCE AND E NGINEERING , T ECHNO I NTERNATIONAL N EW T OWN

Object Oriented Programming Questions

.
January 27, 2022

QUESTIONS
0.1 Question
Design a class Time which stores hour, minute and second. The class should have the methods
to support the following:
1. User may give the time value in 24-hour format.
2. Display the time in AM/PM format.

0.2 Question
Design a Complex class, which have two integer values for real and imaginary part. The class
should have the methods to support the following operations:
1. addition,
2. subtraction,
3. multiplication.

0.3 Question
Design an application for managing information of books, i.e. details of the books and number
of copy of each book title. The application should support the following functions:
1. purchase of new book title, which is not purchased earlier (needs to be implemented
using parameterized constructor),
2. purchase of existing book title (needs to be implemented using copy constructor).

0.4 Question
Design a Student class to store roll, name, course, and marks of 5 subjects. The application
should support:
1. add, delete and modify information of any student,
2. calculate subject wise average of marks,
3. calculate student wise average of marks.

1
0.5 Question
Design an abstract class Shape having 2 methods calculateArea() and display(). Create Rect-
angle and Triangle classes by inheriting the Shape class and override above methods to suit-
ably implement for Rectangle and Triangle class.

0.6 Question
Write a class, Commission, which has an instance variable, sales; an appropriate constructor;
and a method, getCommission() that returns the commission.

Now write a demo class to test the Commission class by reading a sale from the user, using
it to create a Commission object after validating that the value is not negative. Finally, call the
getCommission() method to get and print the commission. If the sales are negative, your demo
should print the message "Invalid Input".

0.7 Question
A small company dealing with transportation has just purchased a computer for its new auto-
mated reservations system. You have been asked to program the new system. You are to write
a program called Reservation System to assign seats on a vehicle. Your class also requires the
following:

1. a constructor method, which initialise the variables


2. method to assign the capacity of seating.
3. method for assigning seats.

0.8 Question
Design a class to calculate the car parking charge in a multiplex. The tax is collected in hourly
basis at a certain given rate. It must support the following activities.

1. Receiving parking charge.


2. Display number of cars at present in the parking lot.
3. Display the time duration and of collected tax per car.

0.9 Question
Design a Account class with account number, balance and date of last updation. Consider
a Transaction class with account number, date of transaction, amount and transaction type.
Check whether the amount is available or not in case of a withdrawal. Transaction object will
make necessary updation in the Account class.

0.10 Question
You have to develop one application for managing Students and Teachers information. They
have some common property, hence you have to define a class Person. Design the application
maintaining hierarchy of classes. Override the toString method to print the values of an object.

0.11 Question
Define a class Employee having private members – id, name, department, salary. Define de-
fault and parameterized constructors. Create a subclass called Manager with private member

2
bonus. Define methods accept and display in both the classes. Create n objects of the Manager
class and display the details of the manager having the maximum total salary (salary+bonus)

0.12 Question
Write a Java program to create a super class Vehicle having members company name and price.
Derive 2 different classes LightMotorVehicle (members – mileage) and HeavyMotorVehicle
(members – capacity-in-tons). Accept the information for n vehicles and display the informa-
tion in appropriate form. While taking data, ask the user about the type of vehicle first.

Each vehicle should have an unique number starting from 100001. This number should be
generated at the time of instanciation.

0.13 Question
Design an application to manage different types of Accounts (i.e. Savings, Demat, Home Loan
etc.). Develop necessary methods to perform account related operations.

An user should be able to do the following:

1. add new account (at least customer’s name, address, PAN and one address proof must be
submitted to open an account)
2. update an account information (customer id can not be changed).

The customer should not able to open a Generic Account (like Account, Loan Account, Deposit
Account etc)

0.14 Question
An application requirement demands a StringFilter that filters out certain alphanumeric char-
acters in an input string. This filter takes the string and returns resulting string removing the
characters that are passed as arguments. Hence, define two classes NumberFilter and Charac-
terFilter.

0.15 Question
SwathiDosaCorner is a famous restaurant and large number of people order various types of
Dosas. There are two types of Dosas available with the restaurant, namely MasalaDosa and
OnionDosa. MasalaDosa is decorated with masala curry, whereas OnionDosa is decorated with
onion scrap. Explain how interfaces can be used to simulate the scenario to pre different dosas
on the request from the client. Illustrate polymorphism involved in this application.

0.16 Question
Design a Calculator having some basic functions like addition, subtraction, multiplication, di-
vision and modulo operations. Design another Calculator having scientific operations like ex-
ponential and logarithmic operations. If any relationship exists between the aforesaid classes
build the relationship. To access the calculator, the user should enter first letter of his/her
name. If user’s name start with A, the user should get basic calculator having only addition and
subtraction method. If user’s name start with S, the user should get scientific calculator having
only addition and subtraction and exponential operation. Rest of the users will get access to
basic calculator having all the functionalities.

3
0.17 Problem Statement
[The following example will be discussed to make you understand a real application]

Design a Scientific Calculator having the aforesaid operations. Restrict the remote users to
access only basic operations whereas the local user will get access to all the operations.

0.18 Problem Statement


Define a class Matrix which contains getElementAt, setElementAt and findItem methods. Add
one more method to add another matrix with this matrix. If dimension of other matrix does not
match, throw an user defined exception AdditionNotPossibleException.

0.19 Problem Statement


Write a program that calls a method that throws an exception of type ArithmeticExcepton at a
random iteration in a for loop. Catch the exception in the method and pass the iteration count
when the exception occurred to the calling method by using an object of an exception class you
define.

0.20 Problem Statement


A bank maintains two kinds of accounts - Savings Account and Current Account.The savings
account provides compound interest, deposit and withdrawal facilities. The current account
only provides deposit and withdrawal facilities. Current account holders should also maintain
a minimum balance. If balance falls below this level, a service charge is imposed. Create a
class Account that stores customer name, account number, and type of account. From this
derive the classes Curr-acct and Sav-acct. Include the necessary methods in order to achieve
the following tasks.

1. Accept deposit from a customer and update the balance.


2. Display the balance.
3. Compute interest and add to balance.
4. Permit withdrawal and update the balance (Check for the minimum balance, impose
penalty if necessary).

0.21 Problem Statement


Design an application to manage different types of Accounts (i.e. Savings, Demat, Home Loan
etc.). Develop necessary methods to perform account related operations.

An user should be able to do the following:

1. add new account (at least customer’s name, address, PAN and one address proof must be
submitted to open an account)
2. update an account information (customer id can not be changed).

The customer should not able to create a Generic Account (like Account, Loan Account, Deposit
Account etc)

Do the necessary changes to support the following features:

1. withdrawal of an amount more than the available balance from a savings account should
through an exception and operation should not be accepted.

4
2. withdrawal of an amount that makes negative balance less the permissible over draft
amount of a credit account should through an exception and operation should not be
accepted.

0.22 Question
Design a Student class with roll, name and score. Support must be there to set the score. Score
is non-negative and cannot exceed 100. For invalid score an exception has to be raised. User of
set score method will decide about the measures to deal with the exception.

0.23 Question
Define a class, MyClass, by inheriting Thread class and create 4 threads with random priority in
the range of 1. . .5. Update a counter for 10 mili-seconds in each of the threads. In these threads
priority will be increased by 1, 2, 2, 1 respectively in every 30 millisecond. Print the priority and
the value of counter for each threads in every 10 milliseconds.

0.24 Question
Design a class Printer that contains print method. The printer can print 1 page in 5 seconds.
Design another class UserRequests which generate print requests in multiple threads. An user’s
print request is generated by a distinct thread. Maximum limit of a print request is 5 page.

Your design should ensure that the printer process the requests one after another in synchro-
nized way. If a printing task has been started, next print task will be started after completion of
the current task.

0.25 Question
Create a list of Students using ArrayList, LinkedList and Vector. Sort the list based on roll
number and Name. Furthermore, display the students information department wise while the
students are sorted by name within a department.

You might also like