Variables Quiz

Below are the answers to the Variables Quiz, along with a brief discussion.

1. Name, type, value.

2. False. You can only use a variable after the point where it has been declared. (This only applies to the local variables that are talked about in this chapter. The instance variables discussed in Chapters 17 and 18 have class scope and can be used anywhere in the class, regardless of ordering.)

3. 1. You only need to declare a variable once. Furthermore, you're only allowed to declare it once. Trying multiple declarations will prevent the code from compiling.

4. answer, value1, delete_me, PI. 1stValue doesn't work because it starts with a number. $message doesn't work because it contains a '$'. delete-me doesn't work because it contains a '-'. The '_' symbol is the only symbol allowed in a variable name.