Memory Flashcards
How does java allocate memory to variables?
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.
What happens when an object is created?
A block of free memory large enough to store the object (its attributes and methods) is allocated to this object.
Is an object stored directly in a variable?
Not necessarily, it could be a reference variable which would refer to an object could be stored in a variable.
What are the Java data types?
Primitive and non-primitive (classes).
What are the 8 primitive Java data types:
boolean, char, byte, short, int, long, float, double
What’s the difference between a primitive and non-primitive type?
A primitive type stores a value, a non-primitive type stores an address
When comparing objects, what’s the difference between “==” and “.equals()”?
== checks if both objects are pointing to the same memory location, whereas .equals() evaluates to the comparison of values in the objects.