disc02.pdf

Pass-by-What?

image.png

  • Draw the box-and-pointer diagram after Java evaluates the main method. What would Java print?
  • On line 19, 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?

Static Methods and Variables

image.png

  • Write what will happen after each call of play()in the following method

image.png

  • If we were to add Cat.nickname("KitKat") to the end of our main function,what would happen?

    Practice with Linked Lists

    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
    image.png

    Solution

    disc02sol.pdf