The JavaTM Tutorial

| Start of Tutorial > Start of Trail > Start of Lesson | Search Feedback Form

Trail: Learning the Java Language
Lesson: Language Basics

## Questions and Exercises: Variables

### Questions

> 1. Which of the following are valid variable names?

>    >     int
>    >     anInt
>    >     i
>    >     i1
>    >     1
>    >     thing1
>    >     1thing
>    >     ONE-HUNDRED
>    >     ONE_HUNDRED
>    >     something2do

> 2. Answer the following questions about the `BasicsDemo` program.
>    1. What is the name of each variable declared in the program? Remember that method parameters are also variables.
>    2. What is the data type of each variable?
>    3. What is the scope of each variable?

### Exercises

> 1. Modify the `MaxVariablesDemo` program so that `aBoolean` has a different value.
> 2. Rewrite the `MaxVariablesDemo` program to display the minimum value of each integer data type. You can guess what the names of these variables are or you can look them up in the API documentation.
> 3. Can you guess the name of a method in the `Character` class that you can use instead of `isUpperCase` to determine the capitalization of a character? Modify the `MaxVariablesDemo` program to use that method instead of `isUpperCase`.

Check your answers.

| Start of Tutorial > Start of Trail > Start of Lesson | Search Feedback Form

Copyright 1995-2001 Sun Microsystems, Inc. All rights reserved.