Q1: | In MS-DOS, I seem to recall that there is a control key command to retype the previous line that you had typed in. Do you happen to know that command? |
A1:
| After opening an MS-DOS Command Prompt window, enter the command doskey. This causes all subsequent commands you type in to be saved, and you can navigate backwards and forwards through these saved commands by using the up arrow and down arrow keys on your keyboard. This can be a timesaver when you're trying to fix a Java program that won't compile successfully. Windows XP supports this functionality automatically. |
Q2: | I have several word processing programs on my system. Which should I use to write Java programs? |
A2:
| Any of them will suffice, as long as the program can save files as text without any special formatting. A word processor that shows the line number your cursor is located on is especially useful. (The Windows programmer's editor UltraEdit-32, for example, shows the line number at the bottom edge of the window along with the column number.) Because the javac compiler lists line numbers with its error messages, the line-numbering feature helps you debug a program more quickly. |
Q3: | How important is it to put the right number of blank spaces on a line in a Java program? |
A3:
| Spacing is strictly for the benefit of people looking at a computer program—the Java compiler could care less. You could have written the Saluton program without using blank spaces or used the Tab key to indent lines, and it would compile successfully. Although the number of spaces in front of the lines isn't important, you should use consistent spacing in your Java programs. Spacing makes it easier for you to see how a program is organized and to which programming block a statement belongs. When you start writing more sophisticated programs, you'll find it much more difficult to do without spacing. |
Q4: | A Java program has been described as a class and as a group of classes. Which is it? |
A4:
| Both. The simple Java programs you create during the next few hours will be compiled into a single file with the extension .class. You can run these with the java interpreter. Java programs also can be made up of a set of classes that work together. In fact, even simple programs like Saluton use other Java classes behind the scenes. This topic will be fully explored during Hour 10, "Creating Your First Object." |
Q5: | If semicolons are needed at the end of each statement, why does the comment line // My first Java program goes here not end with a semicolon? |
A5:
| Comments are completely ignored by the compiler. If you put // on a line in your program, this tells the Java compiler to ignore everything to the right of the // on that line. The following example shows a comment on the same line as a statement:
System.out.println(greeting); // hello, world!
In this example, the compiler will handle the statement System.out.println(greeting) and ignore the comments after the semicolon. |
Q6: | What is a character? |
A6:
| A character is a single letter, number, punctuation mark or other symbol. Examples are T, 5, and %. Characters are stored in variables as text. |
Q7: | I get an Invalid argument error message when I use the javac tool to compile the Saluton program. What can I do to correct this? |
A7:
| You are probably leaving off the .java extension and typing the following command:
javac Saluton
Make sure you are in the same folder as the file Saluton.java, and type the following command to compile the program:
javac Saluton.java
|
Q8: | I couldn't find any errors in the line where the compiler noted an error. What can I do? |
A8:
| The line number displayed with the error message isn't always the place where an error needs to be fixed in your program. Examine the statements that are directly above the error message to see whether you can spot any typos or other bugs. The error usually is within the same programming block. |
Q9: | When orange juice is labeled "not from concentrate," why don't they just call it fresh squeezed? |
A9:
| Orange juice labeled "not from concentrate" is flash-heated to pasteurize it immediately after the fruit is squeezed. It has never been concentrated. "Fresh squeezed" juice has not been pasteurized.
As for other orange juice designations, "chilled or ready-to-serve" is juice made from frozen concentrate or pasteurized juice, and "fresh frozen" is freshly squeezed juice packaged and frozen without pasteurizing or further processing.
Fresh-frozen orange juice is usually sold in a supermarket's frozen food section and is ready to drink after it thaws. |