0% found this document useful (0 votes)
50 views2 pages

Assignment 2: Scientist Manager

The document provides 4 programming assignments involving inheritance and interfaces in Java. The first assignment involves an Employee hierarchy with Scientist and Manager classes. The second involves geometric shapes with Point, Circle, and Cylinder classes. The third involves a Base1, Base2, and Derived class hierarchy. The fourth involves an abstract Employee base class with various worker subclasses like Boss, HrlyWorker, CommissionWorker, and PeiceWorker. Main method is to declare a base class reference and create objects of derived classes to access functions through polymorphism.

Uploaded by

Tanujit Roy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views2 pages

Assignment 2: Scientist Manager

The document provides 4 programming assignments involving inheritance and interfaces in Java. The first assignment involves an Employee hierarchy with Scientist and Manager classes. The second involves geometric shapes with Point, Circle, and Cylinder classes. The third involves a Base1, Base2, and Derived class hierarchy. The fourth involves an abstract Employee base class with various worker subclasses like Boss, HrlyWorker, CommissionWorker, and PeiceWorker. Main method is to declare a base class reference and create objects of derived classes to access functions through polymorphism.

Uploaded by

Tanujit Roy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 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