Solutions to the Try It Out Exercises in Beginning Programming with Java For Dummies, 6th Edition
by Barry Burd

Chapter 4: Exploring the Parts of a Program

In this chapter:

The words in a program

Change the word class to the word bologna. You see a red X and a red underline in Eclipse's editor:

If you click the X or hover over the red underlined word, you see the following message: Syntax error on token "bologna", interface expected

Changing the word args to the word malarkey is okay. The editor doesn't display and error messages and the program runs correctly.

If you change class ThingsILike to public class SomeOtherWord, the error message says The public type SomeOtherWord must be defined in its own file.

If you change println to display, the error message says The method display(String) is undefined for the type PrintStream.

If you remove a pair of curly braces, the error message is Syntax error on token ")", { expected after this token or Syntax error on token "ThingsILike", { expected after this token.

If you comment out the line System.out.println("Chocolate, royalties, sleep") using either the end-of-line or traditional commenting style, the program runs. But you see no output when you run the program. That is, nothing much happens when you run the program.

Valid identifiers

You can change the word args to any of the following words because the following words are valid Java identifiers (names for things): You cannot change the word args to any of the following words because the following words are not valid Java identifiers (names for things):

Your favorite things

public class ThingsYouLike {

  public static void main(String[] malarky) {
    System.out.println("Learning Java, Experimenting with code, Laughing at Barry's jokes");
  }
}