Question
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
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started