As far as I can tell,
Java requires a type for every variable that is declared
ie,
String someString = new String();
String is the TYPE of variable;
someString is the variable TYPE String;
= sets the variable and it's type to refrence what it's pointing to.
In this case new String();
When you create a class ClassDog, you create it like this;
ClassDog newDog = new ClassDog();
ClassDog is the TYPE; newDog is the reference variable
Then when you create a instance variable with the same name, you don't declare it as the same TYPE but as as different TYPE ie;
String newDog = new String();
String is the Type; newDog is the reference variable.
with your example code
By declaring type QuizCardBuilder the JVM allocates memory for the "blueprint" of the class QuizCardBuilder, then, it assigns the refrence variable builder to refer to this specific class model, then with the new invocation actually builds the object from the "blueprint" .
The reason that you have to build the object in the main is that the JVM needs a way to tell what object to build first in your program. The JVM then accesses the class blueprint and runs the static method main, you can run a static method in a class before it becomes an object from just the blueprint of the object. The JVM runs the static method which then creates an object of the QuizCardBuilder class blueprint.
This gives life to
and under additional code there must be a non-static Go() method in this class because the line after the creation of the QuizCardBuilder class says
builder.go();
So if we added that to your code
While you can access static methods as well as static variables before an Object of the Class from the blueprint in this case the main method,
you cannot access any of the non-static methods until the class blueprint has been made into an Object with the new operator
Hope that makes sense;
Have a good day
[ December 16, 2008: Message edited by: Chadd Franck ]