import java.awt.Color; /* * Q: when void? * A: if nothing returned * some methods purpose is to compute something - not void * some methods purpose is to change something - usually void * Q: static * A: means "not part of each object of this type" * * Q: this * q: what object is this talking about? * a: the object (of this type) in question * a: the object that was on the left of the dot in the invoking code * q: why is it used? * a: so that when writing the method I can talk about that object * a: usually we can leave it out and java will guess what we meant * but that code can be ambiguous and hard to read * q: how is it used? * a: by adding this. in front of something * q: when/where is it used? * a: in non-static methods when talking about this object * q: are there other words like "this" in java? * a: no! (but we can fake it) * * Q: How do I do funky things with eclipse? * A: however you choose * * Q: pass-by-______ * A: pass by value: I give you a copy (java: primitives) * pass by reference: I let you mess with my copy (java: objects) * * Q: UML style * A: I don't care * * Q: please plan a UML diagram * * Q: please draw memory * * */ public class Exam2Review { public static int f(int a, int b) { a = 1; b = 2; return 3; } public static void main(String[] args) { System.out.println(Puppy.genus); Puppy.genus = "unkown"; System.out.println(Puppy.genus); Puppy p = new Puppy(); Puppy q = new Puppy(); q.setFurColor(Color.BLACK); p.shed(); System.out.println(q.getFurColor()); p.playWith(q); System.out.println(q.getFurColor()); int a = 3; int b = 5; Exam2Review.f(a, b); System.out.println("a = " + a + "; b = " + b); } }