CS51 - Fall 2009 - Lecture 8

  • Extended discussion of problem 6.9.1 in the book

  • public vs. private
  • by default, instance variables should be private
  • methods can be public or private depending on what they're for
  • parameters as a way of passing information
  • formal parameters in constructor/method declarations
  • actual parameters are passed in when that constructor/method is invoked.
  • what matters are that the types match (or can be converted, for example passing in an int when the method expects a double), and that the order is correct.
  • method overloading
  • two (or more) methods with same name, different signatures
  • convenient to have overloaded methods call each other.
  • use of keyword this