ch3 Flashcards
Can a numeric literal contain a comma?
no
Which object does a variable with the value null
refer to?
To no object at all. There is no null singleton or sth like that in Java.
What is the scope of static variables?
Created: when the class is loaded. Stay: as long as the class stays in the JVM.
What are the possible scopes of a variable?
static, instance / member, local / method / stack (temporary, automatic??), block (Remember: no life outside a class)
What about the variables of the method which has invoked the current method?
They are alive, but out of scope. (They are on the stack, but not in the top étage.)
When do instance variables get a value?
When the object gets created. If no explicit value is defined, they get initialized with a default value.
Is an array an object?
Yes.
int [] numbers = new int[10];
What does this array contain?
10 int elements with the value 0.
Do local variables have a default value?
No.
What happens, if you use a local variable which has not been initialized?
compiler error: might not have been initialized
Reference variables referring to such objects behave a bit different.
String
What does variable shadowing mean?
Reusing a variable name which has already been declared somewhere else.
Which part of the memory is involved in the garbage collection process?
heap
What does the garbage collection do?
- search for objects eligible for garbage collection: No live thread can reach it. 2. evtl delete them
Who starts the garbage collection?
The JVM. The program code can request a run, but there is no guarantee, it will run indeed.