Previous Section  < Day Day Up >  Next Section



Is a line in a Java program the same thing as a statement?


No. Although the programs you will create in this book put one statement on each line, this is done to make the programs easier to understand; it's not required.

The Java compiler does not consider lines, spacing, or other formatting issues when compiling a program. The compiler just wants to see semicolons at the end of each statement. You can put more than one statement on a line, although this makes a program more difficult for humans to understand when they read its source code. For this reason, it is not generally recommended.


Is there a reason to set up a variable without giving it a value right away?


For many of the simple programs you will be creating in the first several hours, no. However, there are many circumstances where it makes more sense to give a variable a value at some point later in the program. One example would be a graphical calculator program. The variable that stores the result of a calculation would not be needed until a user tries out the program's calculator buttons.


What's the specific range for the long variable type?


In Java, a long integer variable can be anything from 9,223,372,036,854,775,808 to 9,223,372,036,854,775,807. This range ought to give your mathematical expressions plenty of breathing room when you can't use int, which has a range of 2,147,483,648 to 2,147,483,647.


Why should the first letter of a variable name be lowercase, as in gameOver?


It makes the variable easier to spot among all the other elements of a Java program. Also, by following a consistent style in the naming of variables, you eliminate errors that can occur when you use a variable in several different places in a program. The style of naming used in this book has become adopted by most Java programmers over the years.


Can two variables have the same letters but different capitalization, as in highScore and HighScore?


Each of the differently capitalized names would be treated as its own variable, so it's possible to use the same name twice in this way. However, it seems likely to cause a lot of confusion when you or someone else is attempting to figure out how the program works. It also increases the likelihood of using the wrong variable name somewhere in your program, which is an error that will not be caught during compilation. Errors such as that that make it into the finished product are called logic errors. They must be caught by an attentive programmer during testing.


Why do a lot of products have a "CE" on their label printed with stylized Greek letters?


The mark signifies that the product is approved for export to 18 countries in the European Union and European Free Trade Association.

CE stands for the French conformité Européenne, which means "European conformity." All products that fall under health, safety, and environmental protection laws in those countries require the mark.

More than you ever wanted to know about CE marking can be found on the Web at

    Previous Section  < Day Day Up >  Next Section