Held Friday, August 27, 1999
Today we begin our study of Java, a modern object-oriented programming
language. While we will cover a great deal about Java in this class,
Java is not the subject of CS152. Rather, it is a tool we
will use to study object-oriented programming, data structures, and
- Introduction to object-oriented programming
- An introduction to Java
- We failed to discuss possible projects yesterday. We might consider:
- A simple image processing/manipulation system
- An email client
- A game
- Any ideas you have
- We'll spend some time during Monday's class discussing possible
- Not all of you noticed that we had an
Please fill it out before Monday morning.
- You can find some of my responses to your questions online.
- As you might guess, object-oriented languages concern themselves with
- You might have a sense of what a ``real world'' object is.
- In computerese, an object is a collection of information
(sometimes called attributes or fields) and
operations that the object can perform (called methods).
- For example, we might say that the textbook for our class
- currently has title ``Java Plus Data Structures'' (attribute)
- is under development (attribute)
- is or will be written by Sam Rebelsky, Chip Weems, and Nell Dale (attribute)
- permits you to search it, at least in the electronic form (method)
- contains text that you can extract (the text is an attribute, the extracting
of the text might be considered a method)
- We often categorize objects into classes. A class specifies
common aspects of a set of objects. These aspects are often
generic attributes and specifications of methods (E.g., ``all objects in
this class have a color, a size, and can draw themselves''.)
- Almost every book has a title
- Almost every book has one or more authors
- Almost every book has text that you can extract
- Most object-oriented languages support inheritance, in which
classes can be based upon other classes. For example, we might say that
library books are a subclass of books and inherit all the
attributes of books. Library books also extend books.
- Since books have titles, library books also have titles
- Since books have authors, library books also have authors
- Library books also have ``loan records'': information on who has
- Some notes on subclasses:
- A subclass inherits the attributes and methods of its
- The parent class is often called a superclass.
- Most object-oriented languages support polymorphism, in which
a member of a subclass can be used in place of a member of a superclass.
- If we know how to read a book, we know how to read a library book.
- Many object-oriented languages are event-driven. That is,
you can specify ``when this event happens, call this method
of this object''.
- A key aspect of object-orientation (and good program design in any
language) is information hiding. In general, objects
should know what other objects do, but not how they
- For example, you might know that a
Menu object can
draw menus on the screen, but it's not important to you how it
- Java is an object-oriented language developed by Sun Microsystems.
- It was ostensibly developed for developing large programs.
- Many of these programs were to run on autonomous systems, like
- With the popularization of the World-Wide Web, it has also
become popular as a language for creating web
- It is also a reasonably good introductory language.
- Java looks a lot like C and C++, two popular languages. It has many
differences from the two.
- It is object-oriented (which C is not but C++ is)
- It has a different view of object-orientation than C++.
- It provides automatic memory management (yay!).
- We'll see some others as time goes on.
- Sun says that Java is ``a simple, object-oriented, distributed,
interpreted, robust, secure, architecture neutral,
portable, high-performance, multithreaded, and dynamic
- Simple. Compared to many modern languages, there is not
too much to the core of Java. However, a great
deal of functionality exists in the standard libraries,
and you will eventually need to learn many parts of those libraries.
- Object-oriented. Java focuses on the creation of classes
and objects. Every Java program begins with a central
class or object.
- Distributed. Java permits you to place different portions
of a program on different servers, to segment
processing between servers, and so on and so forth.
- Interpreted. Although a compiler translates Java code
to another format (byte codes), an interpreter is
required to execute or further translate the byte
- Robust. Java provides a number of facilities for
ensuring that things don't go wrong or that,
when they do, the programmer provides for
- Secure. The Java interpreter will often limit what a
program can do (from accessing the file system to
reading memory outside of a valid range). We often
say that Java gives each program a sandbox
to play in. Note that our HP implementation is somewhat less
secure, and it is possible to crash it in some situations.
- Architecture neutral. A Java program will run
identically (except for speed) on every platform.
Unlike most languages, which can have a different implementation
on every platform, Java has specific requirements for
essentially every part of the language (from the
amount of storage used for various data types to the
algorithms used for numeric computation).
- Portable. See the sections above on architecture neutrality and
- Multithreaded. A program can have separate threads of
computation, and it is relatively easy to manage
- Dynamic. New objects can easily be created, and new
classes can be loaded as the program runs.
- Unfortunately, Java is also a moving target. There have
been at least two major changes to Java since it has been released.
- We will spend the last five or so minutes of each laboratory period
reflecting on some of the things you may have observed or learned.
- How does the way your run Java programs compare to the way you run
- What is similar?
- What is different?
- How does Java compare to Scheme?
Tuesday, 10 August 1999
- Created as a blank outline.
- Filled in the details, mostly taken from
outline 2 of
- Added overview paragraph.
Wednesday, 11 August 1999
- Added the laboratory and reflection sections.
Friday, 27 August 1999
- Added introductory notes.
- Made a few minor corrections.
Back to Introduction.
On to Introduction to Java, continued.