Question: Programming Q uestion: a) Write the definition of a classPersonthat contains anamefield oftype String and anagefeld of type int. Then define two classes,DancerandDonutMaker,that extendPersonsuch thatDancerhas
Programming
Q
uestion:
a)
Write the definition of a classPersonthat contains anamefield oftype String and anagefeld of type int. Then define two classes,DancerandDonutMaker,that extendPersonsuch thatDancerhas an additionalfield calledcompanyof type String, andDonutMakerhas an additionalfield calledshopof type String.
b)Define a classCountingthat contains a methodDancersAges(Person[a]), such that DancersAgesreturns the sum of the agefields of the Dancerobjectsreferenced by the array a. There is no need for an object of classCounting to becreated in order forDancersAgesto be called.
c)Define a classMainClasscontaining themainmethod (for the entireprogram).The mainshould create an array with 10 elements, namely 5Dancerobjects and 5
DonutMakerobjects in alternating order, and passthe array to theDancersAgesmethod, above. You can initialize the fieldsof the objects as you see fit.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
