Overview of Java, JWS

Tom Kelliher, CS 116

Sept. 4, 2000

Administrivia

Announcements

Workload discussion (Section 1).

Handout: the twelve recurring concepts.

Assignment

Study Section 1.5 and the lab handout.

From Last Time

Introduction, background.

Outline

  1. Overview of Java.

  2. Java Workshop.

Coming Up

Lab 1.

Overview of Java

Types of Java Programs

Recurring concept: Levels of Abstraction.

An Applet in Action

  1. HTML:
    <HTML>
       <HEAD>
          <TITLE>
             Hello World Java Applet
          </TITLE>
       </HEAD>
       <BODY>
          Here's my applet...
          <HR>
          <APPLET code="Hello.class"
                  width=150
                  height=60>
          </APPLET>
          <HR>
       </BODY>
    </HTML>
    

  2. Java applet:
    import java.applet.*;
    import java.awt.*;
    
    // The Hello class simply displays the string "Hello, world!"
    // within the graphics object.
    
    public class Hello extends Applet
    {
       public void paint(Graphics g)
       {
          g.drawString("Hello, world!", 20, 10);
       }
    }
    

Run the applet.

Object-Oriented Programming

  1. Modular programming.

    Basic, Pascal, C.

    Control flow model. Flowcharting, pseudo-code.

  2. Object-Oriented programming (OOP)
    1. Definition: A programming methodology that is centered upon the notion of objects which communicate action requests back and forth.

    2. Object: A collection of private data and methods (actions) manipulating the object (actually, its data).

    3. Class: All objects belong to a class. Our Java programs declare and define the classes. Once we define a class, we can begin to use it by declaring objects to be of that class.

      So, objects also have (unique) names.

    4. Inheritance allows us to reuse data and methods from one class in another class. This is extends, although we're really limiting the scope of the class. Also: binding, because we're adding detail.

    5. Libraries: Classes that Java provides for us. We incorporate them with the import statement. What concept(s)?

  3. An example. Wheww, finally. Work on this in groups of two or three:

    Suppose we want to model cars: Tauruses, Civics, etc.

    1. Private data?

    2. Methods (operations)?

    What class do these objects fit into?

    Can we find a hierarchy of classes? (Inheritance) (Start with vehicle.)

Java Workshop

Demonstration:

  1. Creating a new project; adding an existing file.

  2. Compiling the project.

  3. Running the project. Bytecode interpreter.



Thomas P. Kelliher
Fri Sep 1 18:16:31 EDT 2000
Tom Kelliher