Chapter 2: Barons Bk Flashcards
(35 cards)
An object is characterized by its
STATE and BEHAVIOR
•an object is an idea
Object reference
A variable that represents an object
State and behavior of objects
Data fields (instant variables) provide the current STATE •Methods provide the BEHAVIOR and the operations that manipulate the object
Encapsulation
Combining an object’s data and methods into a single unit (class)
Class
A software blueprint that IMPLEMENTS OBJECTS of a given type
•several things can be created/ manipulated by a class
@param
- @param=parameters
* all are instance methods
Public
ACCESS SPECIFIER
Declaration that the class is usable by ALL client programs
•if not public, class can only be used in its own package
Object
What is being created/ manipulated in a program (with the operations that manipulate it)
Private
Keyword that implements info hiding (restriction of access)
Private methods and variables can only be accessed
By methods of that class
Constructor
(Method)
Creates an object of the class. It’s name = class name, no return type (void)
Several constructors provide
Diff ways of initializing class objects
Accessors
ACCESS METHOD: accesses an object w/o altering it, returns some info about object
. Operator (dot operator)
Invokes accessor and mutator method
Indicates that a method is of a specific class
Mutator method
Changes the state of an object by modifying at least one of its instance variables
Instance methods
Operate on individual objects of a class Ex: constructors, accessors, mutators
Static methods
(Class methods) performs an operation for the entire class
If a code calls an instance method or a private instance variable for a nonexistent object
Syntax error occurs
Overloaded methods
2 or more methods in the same class that have the same name but diff parameter lists
The compiler figures out which method the call by examining
The methods signature
Signature
Consists of the method’s name and a list of the parameter types
Example of overloading
More than one constructor in the same class
Overloading constructors provide a choice of ways to
Initialize objects of the class
Scope
Where can you use the variable? Where is it appropriate?
The region in which that variable or method is visible and can be accessed