Chapter 6 Flashcards
What is a class?
It is the template that describes characteristics of similar objects; blueprint to create objects of that class
What is an object?
it is an instance of its’ class
What kind of entity is an object?
It is a run time entity that contains date and responds to messages.
what is encapsulation?
combining data and behavior into a single software package
name the three characteristics of objects
state, behavior, identity
What is the state of an object?
instance variables
What goes into the behavior of an object?
Methods! which define an object’s behavior in response to messages. there are two types: mutators and accessors
What’s the difference between mutators and accessors?
mutators change an object’s state. accessors access the object’s state
what does a computer’s memory hold during execution?
variables that refer to objects, class templates, and objects
Objects appear and occupy memory when instantiated and disappear when no longer need, through a process called ______.
Garbage collection, which is the JVM’s automated method for removing unused objects.
What else does the garbage collection do?
it also tracks whether objects are referenced by any variables.
describe the client and server relationship
Client is the message sender, server is the message receiver. Client only needs to know the interface, server implements and supports the interface
What is an interface?
list of methods
What is information hiding?
server’s data requirements and methods implementation hidden from THE CLIENT
Name the two types of visibility modifiers
private and public.
Define the private visibility modifier
only accessible in the enclosing class
Define the public visibility modifier
class is accessible to anyone
generally, what type of visibility modifiers should instance variables be?
Private! instance variables should generally be private.
What do constructors do?
- initialize a newly instantiated object’s instance variables.
- activated only by the keyword new
What happens with default constructors and their parameters?
Empty parameter lists.
Name the two fundamental data type categories
Primitive (int, double, boolean, char) and reference (all classes, the objects they create.)
what is the null pointer exception?
to cause a variable to no longer point at any object; set it equal to null
should we avoid null pointer exceptions?
yes!!! we really should avoid null pointer exceptions.
true or false: constructors are used when creating an object AND updating or resetting values
FALSE! constructors are only used when creating an object, NOT updating or resetting values