Java: Classes & Objects 2 (6)
the word *aggregate* means __________
"a *whole* that is made of constituent parts" (405)
when an instance of 1 class is a member of another class, it is said that there is a _____ relationship between the classes
"has a" relationship (406)
enumeration [code]
*enum Day { SU, M, TU, W,* *TH, F, SA }* (420)
FACT
*every* class automatically has a *toString* method that returns a string containing the object's class name, followed by the *@* symbol, followed by an integer unique to the object this method is called when necessary if you have *not* provided your own toString method (395)
when a field is *static*, there is ____ [copy] or [copies] of the field in memory, no matter the number of instances of the class
1 (358)
If a class has both static members and instance members, keep the following points in mind:
1. an *instance method* can refer to a *static variable* in the same class 2. an *instance method* can call a *static method* 3. it's *not* necessary to create an object to execute a *static method* (363)
Rules for *overloading constructor* [same as *overloading methods* include:
1. each version of the constructor must have a different signature 2. as long as each constructor has a unique signature, the compiler can tell them apart (369)
FACT
1. inner class is visible only to code inside the outer class 2. the inner class is restricted to the outer class 3. only code in outer class may create an instance of the inner class (419)
ways to help prevent *security holes* in your classes include:
1. perform deep copies when creating field objects 2. return copies of field objects, not the original objects (409)
FACT
2 or more methods in a class may have the same name as long as their signatures are different (364)
419 bullets
419 bullets
CRC stands for _____
Classes Responsibilities Collaboration (434,435)
FACT
If a constructor that accepts arguments is written, we should also write a no-arg constructor.
FACT
Java automatically stores 0 in all uninitialized numeric static member variables (359)
Java: Classes & Objects 2 (6) (357-435)
Java: Classes & Objects 2 (6) (357-435)
copy constructor
a *constructor* that accepts an object of the same class as an argument (400)
null reference
a reference variable that points to nothing (411)
FACT
a string is a reference data type *not* a *primitive* data type
1 copy of a class's static field is shared by _____
all instances of the class (358)
aggregation occurs when ___________
an instance of a class is a field in another class (401,405)
You [*can*] or [can *not*] use the *== operator* to compare the contents of 2 objects
can *not* (396)
*static methods* are convenient for many tasks because they can be *called directly* from the _____ as needed
class (363)
A class's _____ may be overloaded in the same manner as other methods
constructor (369)
reference copy
copying the address of an object into another reference variable (399)
static fields & static methods
does *not* belong to any instance of a class (358)
You can *not* determine whether 2 objects contain the same data by comparing them with the ==operator. Instead, the class must have a method such as _____ for comparing the contents of objects
equals method (396)
every class automatically has a(n) ______ method that works the same as the *== operator* this method is called when necessary if you have not provided your own ____ method
equals method (398)
to be able to compare the objects of a given class, you should always write a _____ method for the class
equals method (398)
the Java Virtual Machine periodically runs a process known as the _____, which removes unreferenced objects from memory
garbage collector (429)
shallow copy
if you make a copy of an *aggregate* object, but only make a reference copy of the objects it references (409)
a(n) _____ is a class inside another class definition
inner class (417)
FACT
it is common for classes to interact, or collaborate, with each other to perform their operations part of the object-oriented design process is identifying the collaborations between classes (431)
when using the *== operator* with reference variables, the operator compares the _____ that the variables contain, *not* the contents of the objects referenced by the variables
memory addresses (396)
FACT
methods being declared *static* belong to the class and may be called without any instances of the class being in existence (361)
FACT
more than 1 *constructor* can be defined for a class (369)
When an *overloaded method* is being called, Java uses the method's ____ and ____ to determine which method to bind the call to
name & parameter list (366)
*static methods* may *not* communicate with _____, only with _____
not with *instance fields*, only with *static fields* (363)
to pass an object as a method argument, you pass an _____
object reference (376)
to show *aggregation* in a *UML* diagram by connecting 2 classes with a line that has a(n) _____ at one end
open diamond ~diamond is closest to the class that is the *aggregate* (408)
the constant's _____ is its position in the enum declaration
ordinal value ~starts at 0 (422)
a method *can* return a(n) _____ to an object
reference (389)
when a method in the *aggregate* class returns a reference to a field object, return a _____ to a copy of the field object
reference (409)
when writing an *aggregate* class, be careful *not* to unintentionally create _____ that can allow code outside the class to *modify* private data inside the class
security holes (409)
enumerated data type
set of predefined values (420)
common use of *this* is to overcome ________
shadowing of a field name by a parameter name (415)
FACT
static class members belong to the class, *not* objects instantiated from the class (357)
FACT
the *return type* is *not* part of the *method signature* (366)
FACT
the garbage collector runs periodically you can *not* predict exactly when it will execute (430)
a method's *signature* consists of the following:
the method's name and the data types of the method's parameters, in the order that they appear (366)
binding
the process of matching a method call with the correct method (366)
the ____ key word is the name of a reference variable that an object can use to refer to itself it is available to *all* nonstatic methods
this keyword (414,415)
if you write a ____ method for a class, Java will automatically call the method when the object is passed as an argument to *print* or *println*
toString method (394)
Java implicitly call an object's _____ method any time you *concatenate* an object of the class with a *string*
toString method (395)
*static methods* are typically used to create _____ classes that perform operations on data, but have no need to collect and store data
utility classes Ex: Math class in the Java Standard Library (363)
primitive data types are passed by _____
value (ch 3)
FACT
when a class contains a *static method*, it is *not* necessary for an instance of the class to be created to execute the method (360)
method overloading
when multiple methods have the same name, but use different parameters ~adds flexibility (364)
FACT
when writing a method that receives a reference as an argument, you must take care not to accidentally modify the contents of the object that is passed (379)
deep copy
when you make a copy of the *aggregate* object, it is important that you also makes copies of the objects it references (409)
the *"has a" relationship* is sometimes called a _____ because 1 object is part of a greater whole
whole-part relationship (406)
FACT
you can *not* know exactly when an object's *finalize* method will execute (430)
FACT
you can *not* make a copy of an object with a simple assignment statement as you would with a primitive variable (398)