Reading Chapter 4 Section 4 - only covers primitives - data members of a class are accessible from all instance methods of the class - how local variables are declared - local variable: variable declared within the method declaration - used for temporary purposes - store intermediate results of a computation - local variables and parameters - accessible only from the method in which they are declared - available only while the method is being executed - memory space - allocated at the beginning of the method - erased upon exiting from the method - how arguments are passed to a method - value of argument passed to parameter in same position in the list - passing occurs when method is called - pass-by-value: - also call-by-value - new memory space is allocated for the parameter - parameter - gets a copy of the argument - is local to the method - changes made to the parameter do not affect the original argument - data type of argument must be assignment-compatible with the data type of the matching parameter - parameter and argument names can be the same - program diagram notation () - how values are returned to a method - data type of the value returned must be assignment-compatible with the declared return type of the method - a call to a method with a return type can be used as an expression - method composition - definition: passing the returned value of a method as an argument to another method - allowed - program diagram notation () : - also use colon notation to designate data member data types : - differentiating data members from local variables and parameters - using the same name for data members and parameters or local variables - valid - not usually recommended - local variable and parameter can never have the same identifier because they are both declared locally - rules for associating an indentifier with a value - if there's a matching local variable declaration or parameter, resolve the identifier to this - otherwise, if there's a matching data member, resolve the identifier to this - otherwise - there is no such data - compiler error - may wish to use an identifier for both a data member and a parameter when setting the data member - use this. to refer to a data member - this is a reserved word - called dot notation - if no local variable or parameter was declared using the same identifier - can still be used - need not be used - common practice not to use unless necessary - avoid naming conflict and use meaningful name by prefixing an article - technique for avoiding a naming conflict is a personal choice Quick Check: 1. local variables: two, three parameters: one data members: one, four 2. the method returns a value and is also declared void 3. methodTwo and methodThree are private 4. public Test (double score) { this.score = score; }