DOC PREVIEW
UMD CMSC 131 - Lecture 12: Runtime Management

This preview shows page 1-2 out of 7 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 7 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 7 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 7 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

CMSC 131 Fall 2007Jan Plane (adapted from Bonnie Dorr)Lecture 12:Runtime ManagementLast time:1.Parameter passing2.Libraries3.Public vs. privateToday:1.runtime stack management2.variable initialization3.function overloading rules4.thisCMSC 131 Fall 2007Jan Plane (adapted from Bonnie Dorr)1Call StackKeeps track of variablesStack FramesStack OperationspushpopEclipse can show the stackCMSC 131 Fall 2007Jan Plane (adapted from Bonnie Dorr)2Initialization of Variables SummaryLocal VariablesParametersInstance VariablesStatic VariablesCMSC 131 Fall 2007Jan Plane (adapted from Bonnie Dorr)3Overloading MethodsTwo methods with the same name but distinguishable parameter typesTerminology:prototype: public static void f(int x, float y)signature: f(int , float ) // names of variables and the return type are not part of itCan’t differ only in return typeCan’t differ only in types that can be implicitly promoted between (widening conversion) when choices are equal in amount of conversionCMSC 131 Fall 2007Jan Plane (adapted from Bonnie Dorr)4Implicit PromotionsOn general assignmentsOn parametersOn return valueCMSC 131 Fall 2007Jan Plane (adapted from Bonnie Dorr)5Most SUBTLE example:Consider overloading like this:void f(int x, double y)void f(double a, int b)Three Calls:f(3, 10.0) f(7.7, 5) f(3, 7)CMSC 131 Fall 2007Jan Plane (adapted from Bonnie Dorr)6thisa reference to the current object. (Only makes sense in a non-static method.)In an instance method, this is the object that is assumedeasy to refer to members (data or methods) using the assumed objectdifficult to refer to the whole object without having a name to call itOnly use when needed – using it all the time makes the code more difficult to


View Full Document

UMD CMSC 131 - Lecture 12: Runtime Management

Documents in this Course
Set #3

Set #3

7 pages

Exam #1

Exam #1

6 pages

Exam #1

Exam #1

6 pages

Notes

Notes

124 pages

Notes

Notes

124 pages

Load more
Download Lecture 12: Runtime Management
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture 12: Runtime Management and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture 12: Runtime Management 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?