CS116      Lab 0 - Introduction to Java

Objectives:

  1. Before starting this lab you should have read Chapter 2 in your text.
     
  2. Open a browser and go to the class web site http://phoenix.goucher.edu/~jillz/cs116/  .  Download both the cs116.zip and mediasources.zip files and unzip them.
     
  3. If you are using the lab machines, I recommend that you store the files directly on your network drive G:\cs116.
    If you are using your own laptop, I recommend that you store the files in your Documents folder.
     
  4. Open DrJava.  Click on EDIT and the PREFERENCES.  This will show the Preferences window as shown on p17 of your text.  Click on the ADD button and browse to the cs116 folder that you previously downloaded.  Click APPLY.
     
  5. From the Preferences Window select INTERACTIONS PANE from the categories on the left.  In the field for the INTERACTIONS WORKING DIRECTORY browse to the cs116 folder once again.  Click OK.  You have now set up DrJava to work with the class files.
     
  6. Click the Reset button on the toolbar to clear and set up the Interactions pane.
     
  7. Select the Tab on the bottom for the Interactions pane. Type each of the following sequences of Java expressions and statements in the Interactions Pane to see what they do.  Note: You should "Reset Interactions" after each sequence by selecting the Reset Interactions under the Tools menu or by right clicking the Interaction Pane and selecting Reset Interactions from the pop-up menu.
     

    Assignment:
    In a text or word document, write out a brief description of what each of the three code fragments is doing and why it works the way it does.

     

     

  8. The Interactions Pane is great for testing out code and we will be using it a lot.  But we will also want to be able to have a Java class that forms a program application that can be executed on its own.  Under the File menu select Open and then browse to your cs116 folder and open the file MyProgram.java. This class has a "main" method that is executed when we execute the class.   You can execute this program by first selecting Compile in the Toolbar and then click Run.   The output of the program will appear in the Interactions Pane.
     


  9.  

    Assignment:
    Edit the code in MyProgram so that it prints out both your names.

     


     

  10. Send your modified code MyProgram.java to me using the GoucherLearn.