Please enable JavaScript to use CodeHS

Chapter 5

Writing Classes

5.1 Anatomy of a Class Access Levels Class Access Instance Variable Access Method Access Rectangle Getter Methods Check Your Understanding Exercise: Access for Employee Class
5.2 Constructors State of an Object The Constructor No-Argument Constructor SuperHero Class Initializing an Object without a Constructor Check Your Understanding Exercise: Dog Class
5.3 Documentation with Comments Introducing Comments Multi-line comments Single line comments Preconditions and postconditions Power Class with Comments Comments for Debugging Check Your Understanding Exercise: Commenting Activity Tracker
5.4 Accessor Methods Accessor Methods The Return Value The toString Method Student Getter Methods SuperHero Class with Secret Identity Check Your Understanding Exercise: Text Messages Getter Methods
5.5 Mutator Methods Mutator Methods Creating Mutator Methods SuperHero Class with Mutator Methods Student Setters Check Your Understanding Exercise: Rectangle class
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 Exercise: Distance Conversions
5.7 Static Variables and Methods Static Variables and Static Methods Skating and Coding Using Static Methods and Variables Static SuperHero Static Variables: Circle Check Your Understanding Exercise: How Many Players in the Game?
5.8 Scope and Access Variables Inside Constructors and Methods Formal Parameters Method Decomposition Instance Variable Scope Local Variable Scope Variable Shadowing Method Decomposition with Trivia Check Your Understanding Exercise: Broken Calculator
5.9 this Keyword this Keyword Use this As An Actual Parameter Rectangles and this Student and this Check Your Understanding Exercise: Write Your Own CodeHS
5.10 Ethical and Social Implications of Computing Systems System Reliability Impacts of Computing Legal and Ethical Considerations Check Your Understanding