


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



cs480 (Prasad) L8Packages 1
cs480 (Prasad) L8Packages 2
cs480 (Prasad) L8Packages 5
same class (^) Y Y Y Y
same package
cs480 (Prasad) L8Packages 6
same package
different package
different package
class S extends C { public int i; protected int j; private int k; int p(C c) { return c.x ; // + c.y + c.z ; }
class C { public int x; protected int y; private int z; int p(C c) { return c.x + c.y + c.z ; }
int q(S s) { return s.x + s.y + // s.z + s.i + s.j + s.k ; }}
int q(S s) { return s.x + s.y +((C) s).y +((C) s).z // + s.z
Scope and Lifetime
the region of text in which the declaration is effective.
bound to an identifier is the period during which it exists in the memory.
Enumeration myEnumerate(final Object[] arr) {
class E implements Enumeration { int count = 0; public boolean hasMoreElements() { return count < arr.length; } public Object nextElement() { return arr[count++]; } } return new E(); }