SJSU/Udacity CS046

Problem Set 2

  1. Circle API
  2. Square Constructor
  3. Car Tester
  4. Instance Variables, Local Variables, Parameters, Return Values
  5. Draw W
  6. Credit Card
  7. Inch Worm
  8. Flower

Circle API

A Circle class has an instance variable radius. Write the code to declare the instance variable radius as a double. private double radius;
Write the header of a constructor for the Circle class. This constructor takes no arguments. public Circle()
Write the header of a constructor for the Circle class. This constructor takes one argument, a double called theRadius. public Circle(double theRadius)

Look at this code segment and then write the Javadoc comment to document the return value of the method.

/**
   Gets the perimeter of the Circle object
   _____________________
*/
public double perimeter()
{
   double result = 2 * Math.PI * radius;
   return result;
}
@return the perimeter Don't worry if your answer was slightly different.
You need to declare your instance variables as _________ so that they can only be accessed by methods of the same class and not by methods of other classes. private

Problem on this page?

Your name:

Your email address:

Problem description:

To protect against spam robots, please answer this simple math problem:
× =