You are on page 1of 2

Assignment 2

Topic: Inheritance, Interfaces Assigned date: 01-09-2019


Submission date: 07-09-2019

Write Java programs for the followings hierarchies with a suitable class for main function. If
required, you are free to add extra data members or instance methods.

Sl Problem Page#
1)
Employee
name
number
Parameterized constructor
printData()

Scientist Manager

publication title
clubDues
constructor constructor
(Parameterized) (Parameterized)
printData() printData()
2)
Point
xCo, yCo
constructor, printPoint()

Circle
radius
constructor, printCircle(),
printArea()

Cylinder
height
constructor, printCylinder(),
printArea()
printVolume()

1
3)
Base1 Base2
val : int letter: char
printBase1() printBase2()

Derived
real : double
printDerived()

4)
* Employee
name : String, EID:int
constructor(), earnings(),
printData()

Boss HrlyWorker
weeklySal : double wage : double
hours: double
constructor(),
constructor(),
earnings(),
earnings(), printData()
printData()

CommissionWorker PeiceWorker
salary : double wagePerPeice : double
commission: double quantity : int
quantity : int constructor(),
constructor(), earnings(), printData()
earnings(), printData()

Note: Make Employee class as ‘Abstract’ base class.

Override functions in derived classes. In the main function declare a


reference of base class and objects of derived classes.

Now access two functions for each different objects using the reference.

You might also like