Exercise 1: Exploring Java™ Programs Errors

In this exercise, your solve compilation and runtime errors.

Preparation

Before your begin, use the cd command in the terminal window to change directories to exercises/mod01_intro/exercise1/.

cd ~/exercises/mod01_intro/exercise1/


Note – For Microsoft Window users, the ~ character in the Unix ® enviroment represents the user's home directory. When you see this character, replace it with the directory hierarchy of your home directory. For stardard Sun Educational Services courses, this directory is \export\home\student. Therefore, the correct cd command to use is:

cd \export\home\studet\exercise\mod01_intro\exercise1\


Task

Perfom the following:

  1. Correct the Test1 program.
    1. Compile the Test1.java file
      Fix any compilation errors and recompile.
    2. Execute the Test1.java file.
      Fix any runtime errors recompile and re-run

  2. Correct the Test2 program.
    1. Compile the Test2.java file
      Fix any compilation errors and recompile.
    2. Execute the Test2.java file.
      Fix any runtime errors recompile and re-run

  3. Correct the Test3 program.
    1. Compile the Test3.java file
      Fix any compilation errors and recompile.
    2. Execute the Test3.java file.
      Fix any runtime errors recompile and re-run

  4. Correct the Test4 program.
    1. Compile the Test4.java file
      Fix any compilation errors and recompile.
    2. Execute the Test4.java file.
      Fix any runtime errors recompile and re-run