Topic 10 - Java Memory Management Flashcards

1
Q

Call stack / runtime stack does what and contains what?

A
Used for method information while the method is being executed.
Contains:
- formal parameters
- local variables
- return value
- where the method should return to
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is Heap used for?

A
Static information (interfaces and classes). 
Instance information (objects).
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What happens when an object is created by the New keyword?

A

1) Reference variable has memory allocated to it in the call stack
2) The object is created using memory in the heap

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

What is being used when a method is being run?

A

Memory space in the call stack / runtime stack.

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

Explain specifically what happens when a method is used / invoked?

A

A call frame (activation record) is created and “pushed” onto the runtime stack.

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

What does the Static space in the heap contain?

A

One copy of the interface and class along with their static variables and methods

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

What does the object space in the heap contain?

A

1) Value of instance variables

2) Type of object

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

What happens to objects after a method returns?

A

Object stays on the heap. Even if there is no longer a variable referencing it. Java has automatic garbage collection.

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