Chapter 3 - Primitives and References Flashcards
Variables come in what two flavors?
Primitive and Object Reference
What are local variables
Variables declared within a method
What are arguments
Values sent to a method by the calling code
What are return types
Values sent back to the caller of the method
Primitives hold?
Fundamental Values (ints, booleans, floats)
Use the dot operator on a reference variable to say?
Use the thing before the dot to get me the thing after the dot
Think of the dot operator as
pressing a button on a remote
An object reference variable is
full of bits representing a way to get to the object
Three steps of object declaration, creation and assignment
Declare a reference variable ... Dog myDog Create an object ... new Dog(); Link the object and the reference ... Dog myDog = new Dog();
Think of a dog reference variable as
a Dog remote control. Use it to get the object to do something (invoke methods)
What’s a null reference
A reference variable that doesn’t refer to anything
Arrays are always
Objects
Declare a dog array variable
Dog [] pets;
What’s a primitive variable value
The bits representing the value
What’s a reference variable value
The bits representing a way to get to an object on the heap