Please enable JavaScript to use CodeHS

Chapter 5

Writing Classes

5.6 Writing Methods

Recap: The Method Header

Passing a Primitive Value

Passing an Object Value

Access to Private Data and Methods

Triangle Class

Baseball Player Class

Check Your Understanding

  1. Incorrect Correct No Answer was selected Invalid Answer

Exercise: Distance Conversions


Term Definition
object.instanceVariable Instance variables can be accessed directly by using the reference variable name + . + the instance variable name. This only works within the class file if the instance variables are set to private.