Chapter 2

The exercises here are taken from my forthcoming book The Java Developer's Resource.

Quiz

  1. What happens if you change the name of the source code file, e.g. HelloEarth.java instead of HelloWorld.java?

  2. What happens if you keep the name of the source code file the same (HelloWorld.java) but change the class's name, e.g. class HelloEarth?

  3. How would you write the Hello World program in French? Spanish? Latin? Arabic?

  4. What's the difference between an operator and a separator?

  5. What's the difference between a keyword and an identifier?

  6. What's the difference between an identifier and a literal?

  7. What would happen if you added the following lines to the Hello World program?

    
    /* THIS PROGRAM CANNOT BE EXECUTED
    WITHOUT SYSADMIN PRIVILEGES */
    

Exercises

  1. Personalize the Hello World program with your name so that it tells you Hello rather than the somewhat generic "World."

  2. Write a program that produces the following output:
    
    Hello World!
    It's been nice knowing you.
    Goodbye world!
    

  3. Write a program that draws the following figures one above the other.
    * * * * *             *  
    * * * * *            * *  
    * * * * *           * * *
    * * * * *         * * * * *
    
    Now modify it to draw them next to each other like above.


[ Exercises | Cafe Au Lait | Books | Trade Shows | Links | FAQ | Tutorial | User Groups ]

Copyright 1996 Elliotte Rusty Harold
elharo@sunsite.unc.edu
Last Modified August 12, 1996