OOP Reference Problem Statements
OOP Reference Problem Statements
OOP Reference Problem Statements
Provide default
and Parameterized constructors. Write a program to perform arithmetic operations of
three complex numbers.
2. Create a class called Employee that includes three pieces of information as instance
variables—a first name (type String), a last name (type String) and a monthly salary
(double). Your class should have a constructor that initializes the three instance variables.
Provide a set and a get method for each instance variable. If the monthly salary is not
positive, set it to 0.0. Write a test application named EmployeeTest that demonstrates
class Employee’s capabilities. Create two Employee objects and display each object’s
yearly salary. Then give each Employee a 15% raise and display each Employee’s yearly
salary again.
3. Create a class called Invoice that a hardware store might use to represent an invoice for
an item sold at the store. An Invoice should include four pieces of information as instance
variables‐a part number(type String),a part description(type String),a quantity of the item
being purchased (type int) and a price per item (double). Your class should have a
constructor that initializes the four instance variables. Provide a set and a get method for
each instance variable. In addition, provide a method named getInvoice Amount that
calculates the invoice amount (i.e., multiplies the quantity by the price per item), then
returns the amount as a double value. If the quantity is not positive, it should be set to 0.
If the price per item is not positive, it should be set to 0.0. Write a test application named
InvoiceTest that demonstrates class Invoice’s capabilities.
4. Create a class called Date that includes three pieces of information as instance variables
—a month (typeint), a day (typeint) and a year (typeint). Your class should have a
constructor that initializes the three instance variables and assumes that the values
provided are correct. Provide a set and a get method for each instance variable. Provide a
method displayDate that displays the month, day and year separated by forward
slashes(/). Write a test application named DateTest that demonstrates classDate’s
capabilities. Perform Validation of Date.
5. Create a super class called Car. The Car class has the following fields and methods. ◦int
speed; ◦double regularPrice; ◦String color; ◦double getSalePrice();
a. Create a sub class of Car class and name it as Truck. The Truck class has the
following fields and methods. ◦int weight;
◦doublegetSalePrice();//Ifweight>2000,10%discount.Otherwise,20%discount
b. Create a subclass of Car class and name it as Ford. The Ford class has the
following fields and methods ◦int year; ◦int manufacturerDiscount;
◦doublegetSalePrice();//FromthesalepricecomputedfromCarclass,subtractthemanuf
acturerDiscount.
c. Create a subclass of Car class and name it as Sedan. The Sedan class has the
following fields and methods. ◦int length;
◦doublegetSalePrice();//Iflength>20feet,5%discount,Otherwise,10%discount.
6. Write a program to create a class named shape. In this class we have three sub classes
circle, triangle and square each class has two member function named Area () and
Perimeter (). Create these using polymorphism concepts.
9. Design and develop inheritance for a given case study, identify objects and relationships
and implement inheritance wherever applicable. Employee class has Emp_name,
Emp_id, Address, Mail_id, and Mobile_no as members. Inherit the classes: Programmer,
Team Lead, Assistant Project Manager and Project Manager from employee class. Add
Basic Pay (BP) as the member of all the inherited classes with 97% of BP as DA, 10 % of
BP as HRA, 12% of BP as PF, 0.1% of BP for staff club fund. Generate pay slips for the
employees with their gross and net salary.
10. Design a base class shape with two double type values and member functions to input the
data and compute_area() for calculating area of shape. Derive two classes: triangle and
rectangle. Make compute_area() as abstract function and redefine this function in the
derived class to suit their requirements. Write a program that accepts dimensions of
triangle/rectangle and display calculated area. Implement dynamic binding for given case
study.
11. Design a class named weather report that holds a daily weather report with data members
day_of_month, hightemp, lowtemp, amount_rain and amount_snow. Use different types
of constructors to initialize the objects. Write a program to generate monthly report that
displays average of each attribute.
12. Identify commonalities and differences between Publication, Book and Magazine classes.
Title, Price, Copies are common instance variables and saleCopy is common method. The
differences are, Bookclass has author and orderCopies(). Magazine Class has methods
orderQty, Current issue, receiveissue().Write a program to find how many copies of the
given books are ordered and display total sale of publication.
13. Design and develop a context for given case study and implement an interface for
Vehicles Consider the example of vehicles like bicycle, car, and bike. All Vehicles have
common functionalities such as Gear Change, Speed up and apply breaks. Make an
interface and put all these common functionalities. Bicycle, Bike, Car classes should be
implemented for all these functionalities in their own class in their own way
14. Design a Base class STACK and Handle runtime anomalies like Overflow when the stack
is full and underflow when the stack is empty. Display error codes and messages by using
appropriate try and catch block to handle the exceptions thrown
15. Implement a program to handle Arithmetic exceptions, Array Index Out Of Bounds. The
user enters two numbers Num1 and Num2. The division of Num1 and Num2 is displayed.
If Num1 and Num2 were not integers, the program would throw a Number Format
Exception. If Num2 were zero, the program would throw an Arithmetic Exception.
Display the exception.
16. You are required to develop a simple console based application for the registration of
voters. Your code should take data form user and save it into a text file. You will make
voter class and a VoterTest class. The Voter Class must have following attributes:
National ID Card Number (This should be primary key),Name,Father/Husband’s name,
Age, Address, Province. Display Voter Registration Form: 1. Add New Voter 2. List All
Voters 3. Find a Voter By Name 4. Exit
17.
18.
19. Identify commonalities and differences between Publication, Book and Magazine classes.
Title, Price, Copies are common instance variables and saleCopy is common method. The
differences are, Bookclass has author and orderCopies(). Magazine Class has methods
orderQty, Current issue, receiveissue().Write a program to find how many copies of the
given books are ordered and display total sale of publication.
20. You are required to develop a simple console based application for the registration of
voters. Your code should take data form user and save it into a text file. You will make
voter class and a VoterTest class. The Voter Class must have following attributes:
National ID Card Number (This should be primary key),Name,Father/Husband’s name,
Age, Address, Province. Display Voter Registration Form: 1. Add New Voter 2. List All
Voters 3. Find a Voter By Name 4. Exit