Memory Flashcards

1
Q

How does java allocate memory to variables?

A

When a declaration of r is processed, a block of memory is allocated to r, at a certain address, which is large enough to store a reference to an object of class r.

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

What happens when an object is created?

A

A block of free memory large enough to store the object (its attributes and methods) is allocated to this object.

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

Is an object stored directly in a variable?

A

Not necessarily, it could be a reference variable which would refer to an object could be stored in a variable.

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

What are the Java data types?

A

Primitive and non-primitive (classes).

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

What are the 8 primitive Java data types:

A

boolean, char, byte, short, int, long, float, double

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

What’s the difference between a primitive and non-primitive type?

A

A primitive type stores a value, a non-primitive type stores an address

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

When comparing objects, what’s the difference between “==” and “.equals()”?

A

== checks if both objects are pointing to the same memory location, whereas .equals() evaluates to the comparison of values in the objects.

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