The Java Tutorials have been written for JDK 8. Examples and practices described in this page don't take advantage of improvements introduced in later releases and might use technology no longer available.
See Java Language Changes for a summary of updated language features in Java SE 9 and subsequent releases.
See JDK Release Notes for information about new features, enhancements, and removed or deprecated options for all JDK releases.
Questions and Exercises: Variables
Questions
- The term "instance variable" is another name for ___.
- The term "class variable" is another name for ___.
- A local variable stores temporary state; it is declared inside a ___.
- A variable declared within the opening and closing parenthesis of a method signature is called a ____.
- What are the eight primitive data types supported by the Java programming language?
- Character strings are represented by the class ___.
- An ___ is a container object that holds a fixed number of values of a single type.
Exercises
- Create a small program that defines some fields. Try creating some illegal field names and see what kind of error the compiler produces. Use the naming rules and conventions as a guide.
- In the program you created in Exercise 1, try leaving the fields uninitialized and print out their values. Try the same with a local variable and see what kind of compiler errors you can produce. Becoming familiar with common compiler errors will make it easier to recognize bugs in your code.
Check your answers