a computer has two forms of memory
primary - main memory, used when running a program, values stored in variables are kept in main memory
secondary memory - used to hold files for permanent storage
what does main memory consist of
long list of numbered locations called bytes - each byte is 8 bits
what is the number called that identifies a byte
address
what happens if more than one byte is needed to store something
several adjacent bytes are used
what is memory location?
an entire chunk of memory that holds the data is called memory location
what happens when a variable is in primitive type?
what happens when the variable is a class type?
only the memory address or reference where its object is located is stored in the memory location
can two reference variables contain the same reference and name the same object?
yes the assignment operator sets the reference (memory address) of one class type variable equal to that of another
what will a change to the object name to a variable do
will produce a change to the object named by the other variable since they are the same object
i.e. if var1 and var2 are referring to the same object and if var1 is change - var2 will also be changed
how does it work when class type variables are store a reference?
how does the assignment operator work with class type variables
all variables in Java are call-by-value
how do class parameters behave differently to prim type parameters?
difference between primitive and class type parameters
what does the “=” do with class type variables
produces two variables that name the same object
what does the “==” do with class type variables
checks that they have the same memory address
unlike .equals method - doesnt check whether their instance variables have the same values
what is null
specialized constant that may be assigned to a class type variable
It is used to indicate that the variable has no "real value"– It is often used in constructors to initialize class type instance variables when there is no obvious object to use - null is not an object: It is, rather, a kind of "placeholder" for a reference that does not name any memory location– Because it is like a memory address, use ==or !=(instead of equals) to test if a class variable contains null
what is the null pointer exception
what does the “new” operator do?
invokes a constructor which initializes an object ad returns a reference to the location in memory of the object created - this reference can be assigned to a variable
what is an anonymous object?
sometimes the object created is used as an argument to a method and never used again - in this case, the object need not be assigned to a variable i.e. given a name
– an object whose reference is not assigned to a variable is anonymous
Double.parseDouble
check with someone?
is using the keyword private enough to prevent privacy leaks?
prim data types - yes class data types - no