Object Instantiation
Reference vs. Object
Let's discuss in more detail what happens for each of these commands:
CyberPet dog;
dog = new CyberPet();
It is important to understand precisely what happens when an object is instantiated in Java (via the new command). It is also important is to understand the subtle difference between the object itself and a variable which references the object.
The null reference and a NullPointerException
Passing Parameters: Value vs. Reference
A related issue is to understand the behaviors associated when passing a primitive data type as a parameter versus passing a reference to an object as a parameter. For this purpose, we examine the code segments in Figures 3-13, and 3-14.
Identifier Scope
When a variable identifier is declared, from where can it be used?
What if there exist two different variables with the same identifier?
Method Overloading
Can a class support two different methods with the same identifier?
Yes, so long as the signatures are different.