Question
Identify the key parts of the Java Class below. Put asterisks next to all the instance variables. Place a box around each constructor. Circle the
Identify the key parts of the Java Class below. Put asterisks next to all the instance variables. Place a box around each constructor. Circle the signature of methods other than the constructor method. Place triangles around the parameters. Underline the return types of methods.
public class Animal {
int weight, height;
double speed;
Animal() {
weight = 50;
height = 4;
speed = 2; //miles per hour
}
Animal(int w, int h, int s ) {
weight = w;
h = height;
speed = s
}
public double getTime(double miles) { //gets the number of hours to go these miles
return miles/speed;
}
public int getWeight() {
return weight;
}
public int getHeight() {
return height;
}
public double getSpeed() {
return speed;
}
}
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