Term
|
Definition
A class is a template or specification for a group of objects.
It defines the attributes of an object and the behaviour, through methods. |
|
|
Term
What is an object in OO-jargon? |
|
Definition
An object, in the domain of object-oriented programming, usually means a compilation of attributes (object elements) and behaviors (methods) encapsulating an entity |
|
|
Term
What does the 'static' keyword do to a variable in Java? |
|
Definition
It creates a class variable instead of an instance variable. All instances of the class will share the same variable.
Additionally, a static variable can be used without an instance of a class being made, e.g.
ClassName.Pi
where ClassName has a static attribute Pi |
|
|
Term
What does this code do?
obj2 = obj1; |
|
Definition
Copies the address of obj1 into obj2, rather than the actual value.
[image] |
|
|
Term
How can you do a bitwise copy of an object? |
|
Definition
Use the clone function.
[image]
|
|
|
Term
What is the inherent flaw when cloning a class instance in Java? |
|
Definition
A deep copy is only done to the original object cloned; any referenced objects are subsequently shallow copied.
[image]
Therefore, a object that references another object cannot be a cloned properly. |
|
|
Term
What three things define a semantic definition equality when implementing an equals() method? |
|
Definition
Symmetric
x.equals(y) <=> y.equals(x)
Reflexive
x.equals(x) == true
Transitive
x.equals(y) && y.equals(z) => x.equals(z) |
|
|
Term
In the declaration:
class Any {
public static final double PI = 3.14159;
}
Describe the properties of the attribute PI and how you would access it. |
|
Definition
The attribute PI is...
Accessible outside the class scope
The same for every instance of the class Any
Constant and cannot be changed
Of native type double
Is accessed by referencing: Any.PI |
|
|
Term
What is the hashcode class and how would you use it? |
|
Definition
A hashcode is the most random number possible derived from an initial value.
To add, do hash, place in index.
To retrieve, get value, hash, and check if the address is populated. |
|
|
Term
What is a variable in object oriented jargon? |
|
Definition
Either...
a property
an attribute
an instance variable
all used interchangably |
|
|
Term
Name these UML connectors and describe the reationship each arrow means:
[image] |
|
Definition
|
|