CMPSC 56 Chapter Notes - Chapter 9: Local Variable, Instance Variable

41 views2 pages
8 Oct 2017
School
Course
Professor

Document Summary

Stack = where method invocations and local variables live. Note: in c++, it is possible to create an object on the stack. To create it on the heap, use a pointer for c++ In java, there is no concept of a variable for an object that isn"t a reference. Amount of memory used to run java program depends on the version of the jvm and on what platform you"re running. Instance variables are declared inside a class, but not inside a method. Local variables are declared inside a method, including method parameters. Stack frame = the new thing that"s pushed onto the stack. The method that is currently executing is on the top of the stack. Remember: non-primitive variables hold references to an object, not the object itself. If a local variable is a reference to an object, only the variable (the reference/remote control) goes on the stack. The object itself still goes to the heap.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents