Class 30.s08 - More on Constructing Classes Scope of an...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: More on Constructing Classes Scope of an identifier = the range of code in which an identifier is known and can be used What is the scope of these identifiers? for (int i =1; i<10; i++) { : // code here } System.out.println (i); while (myScan.hasNext()) { String s = myScan.next(); : //more code } if ( alive ) { double amount = 0; : // more code } amount = amount * 0.7; public void setCode (int c ) { : //code here } public class Car { String make ; int year ; : // lots more code public void setMake (String m) { String make = m; } } Identifer Scope declared inside a block, i.e., between { and } declared at the beginning of a method appearing as a parameter in the api of a method declared as a data member in a class The compiler creates a symbol table to keep track of 430a196f1c45d8b0c9ef75018abfa07df3343397.doc p. 1 Symbol type where defined identifiers. Suppose a local identifier has the same name as an identifier with class scope? public class Car { String make ; int year ; : // lots more code public void setMake (String m) { String make = m; } } Suppose a method has a parameter with the same identifier as a data member? Which identifier is used?...
View Full Document

This note was uploaded on 04/08/2008 for the course WRITING 101 taught by Professor Neverland during the Spring '08 term at Loyola Maryland.

Page1 / 6

Class 30.s08 - More on Constructing Classes Scope of an...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online