Chapter 3: Object-orientated programming Flashcards
Object
An entity that can take on a data-type value.
An instance of a data type.
Data abstraction
The ability to define new data types and to manipulate objects holding data-type values.
8 Primitive data types
- boolean
- byte
- char
- double
- float
- int
- long
- short
Data type
A set of values and a set of operations defined on those values.
API
Application programming interface
A document whose purpose is to provide the information needed to write programs using the data type.
Constructor
Creates an object and returns to the client a reference to the object, not the object itself.
Identity
The memory space associated with the object.
Pointer
An object whose value refers directly to another value stored elsewhere in the computer memory using its address.
Uninitialized variable
A variable that has been declared of a reference type but has not been assigned a value.
3 Essential properties of objects:
- state
- behavior
- identity
State of an object
A value from its data type.
Behavior of an object
Defined by the data type’s operations.
Identity of an object
The place where the object is stored in memory.
What is used to create objects in OOP?
constructors are invoked
How are object states modified in OOP?
instance methods are invoked
Assignment statement
A statement that creates a second copy of a reference.
It does not create a new object, just another reference to an existing object.
Aliasing
The situation where assignment statements don’t create a new object, but rather another reference to an existing object.
Both variables refer to the same object.
Immutable
A data type that has no methods that can change an objects’ value.
public entity
An entity that is accessible by clients
private entity
An entity that is not accessible by clients
final modifier
A modifier that indicates that the value of the variable will not change once it is initialized.
Convention to using public and private
public - Used for all methods and constructors in the API
private - everything else
Typical private methods
Helper methods, used to simplify code in other methods in the class.