03 Disc
03 Disc
1 Static Electricity
1 public class Pokemon {
2 public String name;
3 public int level;
4 public static String trainer = "Ash";
5 public static int partySize = 0;
6
37 }
2 Scope, Static, and Linked Lists
(a) Write what would be printed after the main method is executed.
(b) On line 28, we set level equal to 50. What level do we mean? An instance variable of the
Pokemon class? The local variable containing the parameter to the change method? The local
variable in the main method? Something else?
(c) If we were to call Pokemon.printStats() at the end of our main method, what would happen?
Scope, Static, and Linked Lists 3
2 To Do List
Draw the box-and-pointer diagram that results from running the following code. A StringList is
similar to an IntList. It has two instance variables, first and rest.
4 public SLList() {
5 this.sentinel = new Node();
6 }
7
28 }
(b) Why do we use a helper method here? Why can’t we just have the signature for findFirst
also have a pointer to the curr node, such that the user of the function passes in the sentinel
each time?