Files
G4G0-1/Semester 1/Programming 1/Week 4/Week 4 Programming 1 - Understanding Class Definitions cont..md
2024-01-16 13:48:46 +00:00

664 B

Lecture 1 (11:00) - Class Definitions

  • String is capitalised due to it being a class.

Scope

  • Parameter can only be accessed from the body of the method in which it is declared. We can say its scope is restricted to the body of the method.
  • The scope of a field variable is the body of the class it is declared in.

Lifetime and Accessor Methods

  • Lifetime of a parameter of a method is the duration of a particular call to a method.
  • Value is lost when call completed
  • Lifetime of an objects field variable is the lifetime of the object itself
  • Accessor method allows access to the value of a field without changing the state of an object