(1) statically typed language
every type of variable is checked at compile time before a program is run:
1. declaration of a type is needed
2. after declaration, the data type is fixed
(1) dynamically typed language
you don’t need to say int age=20
can just say age = 20
leads to run-time errors, because the program crashes when it encounters a type it doesn’t expect
(1) bigO-notation (bounded idea)
when we investigate the Big-O notation of a program, the Big-O shows its worst case that the program can take to run.
the program is now bounded by the worst case (from the top).
(2) class
a blueprint describing how objects are built
e.g. its a cookie cutter, and the objects are the cookies
(2) object
a single entity that combines data and behavior
(stores data + can have methods act on it)
(2) instance
a concrete object created from a class
(2) field
a variable/attribute/state of the object
(2) method
an action (behavior) an object knows how to perform
(2) constructor
a code that creates and initializes a new object
- name matches the class name
- no return type
sets initial state of object when it is first created
(2) reference
a special variable that points to an object in memory (a pointer to memory location where the stuff is actually stored)
(2) encapsulation
controlling how data is accessed (the fields are private but the methods to access the fields are public)
(2) access modifier
rules that limit the visibility of fields and methods (private/public)
(2) this
a reference to the current object
(2) syntax for creating objects (creating an object e1 in an Elephant class)
Elephant e1 = new Elephant();
(2) constructor overloading
having multiple constructors with the same name, different parameters
(2) this()
calls another constructor in the same class
constructor hands off work to another constructor in the same class
(2) toString()
string representation of current state of object
(2) implicit call + toString() example
automatically invoked method
(2) composition
one object contains another
ex. a circle has a point
(2) constant
value declared with final (cannot be changed)
(2) empty/default constructor
sets the object to its default value
nothing in parenthesis - what happens when no input is given for the object
uses a this() so that it can delegate to the real constructor
(2) this.
use this. when your box name = parameter name to differentiate between what is box and what is parameter
(2) getters and setters
getters
- no parameters
- returns a value
setters
- has parameters
- returns void
- maintains invariants (validates data before assigning it to box)