Chapter 3 - Primitives and References Flashcards

1
Q

Variables come in what two flavors?

A

Primitive and Object Reference

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are local variables

A

Variables declared within a method

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are arguments

A

Values sent to a method by the calling code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are return types

A

Values sent back to the caller of the method

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Primitives hold?

A

Fundamental Values (ints, booleans, floats)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Use the dot operator on a reference variable to say?

A

Use the thing before the dot to get me the thing after the dot

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Think of the dot operator as

A

pressing a button on a remote

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

An object reference variable is

A

full of bits representing a way to get to the object

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Three steps of object declaration, creation and assignment

A
Declare a reference variable ... Dog myDog
Create an object ... new Dog();
Link the object and the reference ... Dog myDog = new Dog();
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Think of a dog reference variable as

A

a Dog remote control. Use it to get the object to do something (invoke methods)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What’s a null reference

A

A reference variable that doesn’t refer to anything

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Arrays are always

A

Objects

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Declare a dog array variable

A

Dog [] pets;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What’s a primitive variable value

A

The bits representing the value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What’s a reference variable value

A

The bits representing a way to get to an object on the heap

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

A reference variable is like?

A

A remote control

17
Q

When does a reference variable have a null value

A

When it’s not referencing any object

18
Q

Arguments

A

Values sent to a method by the calling code

19
Q

Return types

A

Values sent back to the caller of the method

20
Q

Think of a variable as?

A

A coffee cup. It holds something. It has a size and type

21
Q

A variable needs a name so

A

you can use that name in code

22
Q

myDog.bark() means

A

use the object referenced by the variable myDog to invoke the bark() method.

23
Q

An object reference is just

A

another variable value

24
Q

Primitive variable

A

byte x = 7;

The bits representing 7 go into the variable

25
Q

Reference variable

A
Dog myDog = new Dog();
The bits representing a way to get to the Dog object go into the variable
26
Q

An array is like?

A

A tray of cups

27
Q

Every element in an array is just a?

A

A variable. Primitive or Reference

28
Q

In a dog array each element can hold

A

a remote control to a Dog.

29
Q

When the dog is in an array we don’t have?

A

an actual variable name. Use array notation and push the remote on an object a particular index in the array.

Dog[] myDogs = new Dog[3];
myDogs[0] = new Dog();
myDogs[0].name = "Fido"
myDogs[0].bark();