1. Is each of the following class identifiers (a) legal and conventional, (b) legal but unconventional, or (c) illegal?

    a. myClass b b. void c c. Golden Retriever c d. invoice# c e. 36542ZipCode c f. Apartment a g. Fruit a h. 8888 c i. displayTotal() c j. Accounts_Receivable b
  2. Is each of the following method identifiers (a) legal and conventional, (b) legal but unconventional, or (c) illegal?

    a. associationRules() a b. void() c c. Golden Retriever() c d. invoice#() c e. 36542ZipCode() c f. PayrollApp() b g. getReady() a h. 911() c i. displayTotal() a j. Accounts_Receivable() b


  3. Name at least three attributes that might be appropriate for each of the following classes:

    a. RealEstateisting streetAddress, numberOfBedrooms, price b. Vacation lengthInDays, destination, cost c. CreditCardBill creditCardNumber, nameOnAccount, amountDue
  4. Name at least three real-life objects that are instances of each of the following classes:

    a. Song Happy Birthday, Star Spangled Banner, All You Need is Love b. CollegeCourse History 102, English 200, Math 101 c. Musician Yo-Yo Ma, Vladimir Horowitz, Eric Clapton
  5. Name at least three classes to which each of these objects might belong:

    a. myGrandmothersBrooch Jewelry, Antique, Possession b. eggsBenedict Breakfast, EggDish, ExpensiveMeals c. cookieMonster SesameStreetCharacter, BlueCharacter ChildrensCharacter
  6. Write, compile, and test a class that displays the first few lines of the lyrics of your favorite song. Save the class as SongLyrics.java.

    public class SongLyrics { public static void main(String[] args) { System.out.println("Somewhere over the rainbow"); System.out.println("Way up high"); System.out.println("There's a land that I heard of"); System.out.println("Once in a lullaby"); } }
  7. Write, compile, and test a class that displays your favorite movie quote, the movie it comes from, the character who said it, and the year of the movie. Save the class as MovieQuoteInfo.java.

    public class MovieQuoteInfo { public static void main(String[] args) { System.out.println("Rosebud,"); System.out.println("said by Charles Foster Kane"); System.out.println("in the movie Citizen Kane"); System.out.println("in 1941."); } }
  8. Write, compile, and test a class that displays the pattern shown in Figure 1-25. Save the class as TableAndChairs.java.

    public class TableAndChairs { public static void main(String[] args) { System.out.println(" "); System.out.println("X X"); System.out.println("X X"); System.out.println("X XXXXXXXXXX X"); System.out.println("XXXXX X X XXXXX"); System.out.println("X X X X X X"); System.out.println("X X X X X X"); } }
  9. Write, compile, and test a class that displays the pattern shown in Figure 1-26. Save the class as Triangle.java.

    public class Triangle { public static void main(String[] args) { System.out.println(" "); System.out.println(" T"); System.out.println(" TTT"); System.out.println(" TTTTT"); System.out.println(" TTTTTTT"); System.out.println(" TTTTTTTTT"); System.out.println(" TTTTTTTTTTT"); System.out.println(" TTTTTTTTTTTTT"); } }
  10. Write, compile, and test a class that uses the command window to display the following statement about comments: Program comments are nonexecuting statements you add to a file for documentation. Also include the same statement in three different comments in the class; each comment should use one of the three different methods of including comments in a Java class. Save the class as Comments.java.

    public class Comments { public static void main(String[] args) { System.out.println("Program comments are nonexecuting statements "); System.out.println("you add to a file for documentation."); // three line comments // Program comments are nonexecuting statements // you add to a file for documentation. // one block comment /* Program comments are nonexecuting statements you add to a file for documentation. */ // one javadoc comment /** Program comments are nonexecuting statements you add to a file for documentation. */ } }
  11. Modify the Comments.java program in Exercise 10 so that the statement about comments is displayed in a dialog box. Save the class as CommentsDialog.java.

    // CommentsDialog.java // Chapter 1, Exercise #11 // Displays comments in dialog box import javax.swing.JOptionPane; public class CommentsDialog { public static void main(String[] args) { JOptionPane.showMessageDialog (null, "Program comments are nonexecuting statements you add" + "\nto a program for documentation."); // three line comments // Program comments are nonexecuting statements you add // to a program for documentation. // one block comment /* Program comments are non-executing statements you add to a program for documentation. */ // one javadoc comment /** Programming comments are non-executing statements you add to a program for documentation */ } }
  12. From 1925 through 1963, Burma Shave advertising signs appeared next to highways all across the United States. There were always four or five signs in a row containing pieces of a rhyme, followed by a final sign that read “Burma Shave.” For example, one set of signs that has been preserved by the Smithsonian Institution reads as follows: Shaving brushes You'll soon see 'em On a shelf In some museum Burma Shave Find a classic Burma Shave rhyme on the Web. Write, compile, and test a class that produces a series of four dialog boxes so that each displays one line of a Burma Shave slogan in turn. Save the class as BurmaShave.java.

    import javax.swing.JOptionPane; public class BurmaShave { public static void main(String[] args) { JOptionPane.showMessageDialog(null,"Shaving brushes"); JOptionPane.showMessageDialog(null,"You'll soon see 'em"); JOptionPane.showMessageDialog(null,"On a shelf"); JOptionPane.showMessageDialog(null,"In some museum"); JOptionPane.showMessageDialog(null,"Burma Shave"); } }