Question: Declare a public class named Elephant and declare two private instance variables named height and weight in the class. Both variables are of type double.

Declare a public class named Elephant and declare two private instance variables named height and weight in the class. Both variables are of type double. Declare a default constructor which initializes the variables to 0.0, then declare an overloaded constructor which accepts two double parameters representing the height and weight of the Elephant object. In the overloaded constructor initialize the instance variables using those parameters.

No main method, accessors, or mutators are required for this problem.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!