M5 pt 2 Flashcards
declared either at the start or end
of a class definition. These variables identify
the data stored in the object.
Attributes –
a method that is automatically
executed when an object is created. This
method is used to initialize the attributes.
Constructor –
a method that is used
to change the data.
Mutator (Setter) –
a method that is
used to access or retrieve data.
Accessor (Getter) –
implement the business
rules for which the application is being
developed
Custom Methods –
Steps in Declaring Classes
- Define the class name
- Declare the attributes
- Create constructor
- Create standard methods
- Create custom methods
class declaration syntax
class { //code }
attributes declaration syntax
ex. private String name;
constructor declaration syntax
- {
- //code here
- }
Create standard methods (setters) syntax
- setXxx(args list)
- {
- //codes here
- }
Create standard methods (getters) syntax
- getXxx (args list)
- {
- //codes here
- }
Create custom methods syntax
- {
- //codes here
- }
contains a reference to the current object being
constructed. It represents an instance of the class in
which it appears. It can be used to access class variables
and methods.
this keyword
can be used to refer current class instance variable.
this()
can be used to invoke current class constructor.
this()