go to previous page   go to home page   go to next page

Answer:

double


Filling in the Definition

The names of the variables are up to the programmer, but it is helpful to give them meaningful names.

Here is Cone with some parts filled in filled in:


public class Cone
{
  // instance variables
  private double radius;  // radius of the base
  private double height;  // height of the cone
 
  // constructor


  // methods

}

(Review: ) An instance variable is a variable that holds part of the state of an object. Each object (each "instance" of the class) contains its own instance variables. Instance variables hold on to their values as long as the object exists. An assignment statements can change the value in an instance variable, but otherwise it holds its value for the lifetime of the object.


QUESTION 6:

(Review: ) What must the constructor of Cone be named?


go to previous page   go to home page   go to next page