Definitions
Class - A program entity that represents either a template for a new type of object
Object - An entity that combines state and behavior
Object-oriented programming(OOP) - Programs that perform their behavior as interactions between objects
Abstraction - A distancing between ideas and details
Field - A variable inside an object that is part of its state
Declaration Syntax:
type name;
Accessing an object's fields
variable.field
Modifying an object's fields
variable.field = value
null - A value that does not refer to any object
dereference - To access data or methods of an object with dot notation, such as s.length() (It is illegal to derefence null)
Instance method(object method) - Exists inside each object of a class and gives behavior to each object
Syntax:
public type name(parameters) {
statements;
}
Implicit parameter - The object to which an instance method is called
accessor - A method that lets clients examine object state
mutator - A method that modifies an object's state
constructor - Initializes the state of new objects
public type(parameters){
statements;
}
Encapsulation - Hiding implementation details from clients
private fields - A field that cannot be accessed from outside the class
Syntax:
private type name;
this - Refers to the implicit parameter inside your class
Refer to a field: this.field
Call a method: this.method(parameters);
One constructor can call another: this(parameters);
shadowing - 2 variables with same name in same scope
(Normally illegal,except when one variable is a field)
module - A resuable piece of software, stored as a class
static - Part of a class, rather than part of an object.
Not copied into each object; shared by all objects of that class
static fields - stored in the class instead of each object
A "shared" field all objects can access and modify
syntax:
private static type name;
private static type name = value;