CIS 120 Final: CIS 120 UPenn Final sp11 solutions

31 views20 pages

Document Summary

If the initialization is invalid, write invalid in both blanks. Assume that these statements occur in order, and that invalid initializations do not prevent subsequent lines from referring to the variable. If they misread and put the correct static type for the two. 1 (b) (10 points) draw the state of the abstract stack machine just after the variable z has been pushed onto the stack. A sample asm (from lecture 28) appears in the appendix. A b = new b(1,3); int z = b. getx(); Grading scheme: stack variable b, stack variable x, object in heap b, eld x, eld x1, eld y, a in class table, getx in a, b in class table, getx in b. 2 (c) (5 points) brie y de ne the terms static type and dynamic class in java. Answer: the dynamic class of an object is the class that the object was created from.