Public vs. private
public
- methods and fields exposed to others
private
- methods and fields visible only to internal methods
- allows one to write "safe" objects; we want objects that maintain correct internal state
- corrupt state (aka bug) is the usual cause of program failure
protected
- methods and fields exposed to subclasses
- (more on this next lecture when we cover inheritance)