Please enable JavaScript to use CodeHS

Chapter 5

Writing Classes

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

  1. Incorrect Correct No Answer was selected Invalid Answer

Exercise: Broken Calculator

Vocabulary

Term Definition
Method Decomposition The process of breaking down large problems into smaller problems, each with a method that defines a subproblem in the larger problem.
Shadowing If two variables within the same scope have the same name, the variable with the more specific scope will be called.
Local Variable A variable that is defined in a method or constructor. It only exists in the context of the method that it belongs to.