Java with OO Review
 

This page is for students enrolled in the Spring 2008 Java Programming Language Raytheon in-house course.

 Course Info

 Course Outline

 Links 

 Instructor 

 Prerequisites

 Java Programming Terminology

 Object technologies

 Homework

 Shapes Project  Updated! 6-25

 

 MusicPlayer Project Updated 7/16!

 

Updates:

16 July - Music Player project has been updated, it's looking pretty cool if I dare say so.  Bugs are all fixed, several features added, including an animated graphic.

10 July - I've added a MusicPlayer project that is a mp3 and wav file player.  We'll switch over to this project, and using NetBeans 6.1, focus on it for the rest of the class.  The player is still a bit buggy, but does manage to do quite a bit correctly, using the same third party mp3 player from javazoom that I used in the Shapes project.  And I changed the homework assignments around.

25 June - Shapes has been updated to include some of the next homework assignment.  The version posted will play mp3 files and prints the start, stop, and elapsed times.  I've also brought up the project in NetBeans 6.1.

15 June - I've altered the homework assignments somewhat, giving us more flexibility.  See below.  Any statement or impression I may have given implying that you can't do graphics with BlueJ is incorrect - there's just no graphics editor to make it particularly easy to do it.  The latest version of Eclipse does not include a graphics editor as you may be used to with an IDE like Visual Studio or Lab Windows/CVI.  There is an Eclipse GUI editor, but it runs on the older "Callisto" release (3.2) of Eclipse rather than on the current "Europa" release.  So I am having some second thoughts about using Eclipse exclusively - there's a nice version of NetBeans that's tailored for use with BlueJ - you can concurrently work on the same project from both BlueJ and the NetBeans IDE.  You can enable the more advanced features of the NetBeans IDE as you're ready for them - by default, the NetBeans BlueJ edition has some of NetBeans' more advanced features disabled so as to present a simpler user interface.  We'll talk about this in class, but right now NetBeans is looking a bit more attractive to me than Eclipse.  The latest NetBeans version, 6.1, includes an integrated GUI editor, UML diagramming, profiling, etc. In the "IDE" wars, NetBeans seems to have forged ahead of Eclipse for the time being.

I've uploaded the Shapes project with the music file select popup incorporated.  Right now I have it so it will select and play .wav files only, but Sun has available a media framework (Java Media Framework 2.1.1e) that includes an mp3 player, or you can use some classes from javazoom.  I've added info below in the homework section that will help you do this assignment.

12 June - Well, I have Shapes cleaned up a bit more - I incorporated the changes suggested by one of our students (Jim) to eliminate the casts I was doing in Test - Bjarne is right - most casts are an indication of a design error.  And I fixed up Kite - I eliminated the constructor that used diagonals only (infinite set of kites that satisfy a given set of diagonals - duh) and now have it properly implemented along with scaleable interface.  I did kludge up a ShowScalables function in Test to print Scalable collections.

11 June - Tweaked Shapes a bit to refactor functions.  A student has identified an implementation that avoids the casts I was using in the Collections, I'll incorporate that fix.

4 June - I've put up the Shapes project with the Homework 3 solution implemented.  I do have an improper solution for the Scaleable interface for the Trapezoid class at this point - I'll catch up to this (probably when I finally manage to do a meaningful Polygon class :-).

28 May - I've uploaded a Shapes jar file with Ellipse and Polygon classes.  The Polygon class is pretty weak, I'll add more to it later and put it up on the site.

21 May - I just noticed that Sun is willing to certify you as a Java developer if you give them some money and go to an exam center and take a multiple choice test.  Passing is 68% ?!  This is just not very hard folks - you should be able to pass the "Sun Certified Java Associate" after taking this class (if you've done the homework and paid attention during class).  Check it out.  You should be able to take and pass the "Sun Certified Java Programmer" certification with some work.  You can give Sun a little less money and take practice exams.  The closest examination center is in Ventura.

I tweaked the Shapes project some more.  Nothing major, but you may have to rework your solutions a bit.

14 May - I've modified the Shapes project to better define the abstract class Triangle, and I've changed the notation used to something more conventional.  Look at the comment in the Triangle class to see the notation.  I've added statements to the main method of Test to create and use triangles of the three types.  When you're ready to try out your implementation, uncomment these statements to check your work.  If you're having trouble remembering your geometry, you might look here and maybe here too.  Yup, those movable triangles you see at the second link are Java applets.  And as a final clue (I am getting soft in my old age) I'd use these constructors:

public EquilateralTriangle (double dSideabc) { … }
public ScaleneTriangle (double dSidea, double dSideb, double dAngleC) { … }
public IsocelesTriangle (double dSideac, double dAngleB) { … }

Goals:

To review Object Orientation fundamentals.  To learn the Java Programming Language.

Class Schedule:

Twelve one-hour meetings, Wednesdays at noon starting 7 May 2008. Building B1, Room S827. (Computer training room on North side of the building). Each hour attended counts towards training time. Roll is taken (via a sign-in sheet) at every class, and your attendance is recorded in the training database.

Text:
 
 Core Java, Volume 1 - Fundamentals, 8th Edition.  Cay S. Horstmann and Gary Cornell. ISBN 978- 0132354769

The book is provided to students at no cost by the company.  There are countless books on Java, available at any bookstore with a computer section.  This particular book is something of a classic, having been around since the early days of Java, and it's been updated to keep track of new developments.  The book describes the use of the Java Developer's Kit (JDK) and the Eclipse IDE, but is not referent to BlueJ (see below). 

 

Other popular Java books include:

The O'Reilly books: 

Java Generics and Collections.   Maurice Naftalin and Philip Wadler,  ISBN 0596527756

 

Hardcore Java.  Robert Simmons.  ISBN 0596005393

 

Eclipse IDE Pocket Guide. Ed Burnette.  ISBN 0596100655

 

Java in a Nutshell, 5th Edition.  David Flanagan, ISBN 0596007736

 

And:

 

Core Java, Volume II: Advanced Features, Cay Horstmann, Gary Cornel, ISBN 978-013235479

 

Core J2EE Patterns: Best Practices and Design Strategies, 2nd Edition. ISBN 0131422464

 

Java Puzzlers: Traps, Pitfalls, and Corner Cases, Joshua Bloch, Neal Gafter. ISBN 032133678X

 

Objects First with Java, A Practical Introduction using BlueJ, 3rd Edition. David Barnes & Michael Kölling. ISBN 0-13-197-629X

 

Thinking in Java, 4th Edition,  Bruce Eckel.  ISBN 0-13-187248-6.  You can download a PDF copy of the 3rd edition for free here.

 

Instructor:

Robert G. (Bob) Hayes, Senior Principal Software Engineer, Raytheon Vision Systems. Bob has been designing software systems at Hughes Aircraft/Raytheon for 35 years.  He holds a BSE in Electrical Engineering and an MS in Computer Science.

Prerequisites:

This course is for experienced programmers who want to learn how to write useful Java applications.  A basic understanding of object orientation is a plus:  the course will start with two sessions of review of Object Orientation.  Reading and doing exercises outside of class will be required for anything except a very cursory understanding of the material.   Access to a PC for performing programming exercises will be necessary.  You can use a Mac if you prefer, or Unix / Linux.  In every case, if you download and install software to a Raytheon owned PC, follow the company practice for installing licensed software.

Other:

The only way to really learn/understand a programming language is to write code, a lot of it. Expect to do exercises in class and on your own.  Working together on exercises is allowed and expected.

BlueJ:

A nice, clean Java environment for learning the language is the BlueJ IDE (Integrated Development Environment) offered for free from www.bluej.org. Developed by European academics, BlueJ runs on top of the Java JDK (Java Developer's Kit) which can be obtained, again for free, from Sun's Java website http://java.sun.com.  BlueJ allows the student to quickly start creating classes and running programs, in a more benign environment than that offered by the Java SDK.  BlueJ uses a UML (Unified Modeling Language) class diagram to create class hierarchies, and can do some other very cool things, such as:

  • Create an instance of a class with a simple key-click.
  • Automatically create Java skeleton code for a class.
  • Execute methods without having to create public static void main().
  • Automatically create interface documentation in HTML using javadoc.
  • Simple text editor and debugger.
  • Migration path to NetBeans IDE with special BlueJ version of NetBeans

This is a very cool tool, especially when you consider that it's free.

Eclipse:

Eclipse is a free, open, full-featured Java IDE developed initially by IBM and now governed by a not-for-profit group.  Eclipse has become the IDE of choice for many Java developers, and we'll use it during the class.

Java at Raytheon:

What is likely the largest software development underway at Raytheon?  Raytheon is systems integrator for the new DDG 1000 destroyer - and they're using Java!  The Real Time Specification for Java (RTSJ), to be exact.  Read about it here.  Here's an article about Java's movement into the embedded domain, including military systems such as those we design and create at Raytheon.

In a quick search on the Raytheon internal job-opening site, RayCats, I found 20 open reqs asking for C# experience.  I found 141 asking for Java!  And almost all of them ask for an understanding of UML.

Links:

Here are some useful links. There is an immense amount of useful information on OO and on Java available on the web.

http://java.sun.com          Sun's Java site.  Everything Java.  You can download the SDK and NetBeans here, also Java tutorials.

http://www.bluej.org        A nice (but limited) development environment for learning OO using Java.  It's free.

http://www.netbeans.org   Despite the innocuous URL, this is Sun's IDE.  Current version 6.1 maybe the best free IDE available.

http://www.eclipse.org  A popular free Java IDE, and one we'll use in this class, though we'll start with BlueJ.

http://www.cetus-links.org Cetus. 18,000+ links on all things OO.  This page hasn't been maintained for quite a while now.

http://www.cs.lmu.edu/~ray/notes/introjava       Professor Ray Toal's Intro to Java page. 

http://www.cs.lmu.edu/~ray      Ray's site.  Lots of good things on these pages, Ray has been LMU's Teacher of the Year.  Notice all of the cool papers Ray and I have co-authored :-)

C#   Vs.  Java comparison

A detailed C#  Vs. Java comparison

Java  Vs.  C# - a code for code comparison

Class text web page

MathOpenRef   So you can figure out the geometry.

 

Back to top

 

Course Outline:

We'll generally follow the following outline, though we may diverge from it or even omit certain topics altogether.  We'll do programming exercises throughout the class.

·       Object Orientation Review (two class meetings)

·       The Object Model

·       Classes and Objects

·       Java

·       History of Java

·       Key features/getting past the hype

·       Fundamental Programming Structures

·       Objects and Classes

·       Inheritance

·       Interfaces and Inner Classes

·       Java and the Web - Java WebStart

·       The Java Virtual Machine

·       Generics and Collections

·       Java ME and Java EE

·       Java IDE's - Eclipse, NetBeans, and BlueJ

·       The Real Time Specification for Java

·       C# Vs. Java

 

Back to top

 

Homework 1:

1.       Read chapters 1 (Introduction), 2 (Programming Environment), and 4 (Objects and Classes) of the text.   I also recommend starting the Java tutorials on the Java homepage.

2.       Download and install JDK 6 (Java Developer's Kit) to a computer you can use for programming.  I recommend downloading JDK 6 update 6.  The beta version is, well, a beta version, and the other versions include other stuff you don't need right now.  You need the JDK, not just the JRE (Java Runtime Environment).  After you install the JDK, you can test your JRE installation here.  If you're installing to a Raytheon computer, be sure to follow the company policy for installing licensed software.

3.       Download and install the BlueJ IDE.  Do this only after you've successfully installed the JDK.

4.       Download the Shapes project, and run it to verify that everything's set up properly.  The project is in the form of a JAR (Java Archive) file, and can be loaded directly into BlueJ.  I may tweak this project from time to time, so periodically check to see if it's been updated.

5.       Enhance the Shapes project to complete the Triangle subclasses.  You will need to alter only the three Triangle subclasses - do not alter any others, including the Triangle class.  Provide a default constructor for each Triangle subclass.  Use one of the Shape subclasses I've implemented to get an idea of what is needed.  I've added code to the Test class to use the Triangle subclasses, you can uncomment these statements to check your work. 

Homework 2:

1.       Read chapters 3 (Fundamental Programming) and 5 (Inheritance)of the text.  Continue following the Java tutorials.

2.       Refactor the class hierarchy in Shapes to include either a Polygon class or an Ellipse class.  Should the Ellipse class be a superclass of Circle, or the other way around?  Make any simplifying assumptions or approximations you care to if you implement Ellipse, and feel free to redefine Circle if that helps.  Assume a regular polygon too, that will help.  Where in the class hierarchy should you insert the Polygon class?  Why?  Make sure all of the existing subclasses work as originally designed after you add the Polygon or Ellipse classes.  Was it easier to implement the concrete Triangle subclasses in Homework 1, or the classes in this homework?  Why?

Homework 3:

1.       Read chapters 6 (Interfaces and Inner Classes), 12 (Generic Programming), and 13 (Collections) of the text.

2.       Add an Interface Scaleable to the Shapes project.  Scaleable contains a single method,

 void Scale (double dScaleFactor);

 which rescales a Shape using dScaleFactor in some sensible way, you decide how.

3.       Add code to the Shapes Test class main() to create, fill, and print a sorted collection of Shapes as a TreeSet.

4.       Add code to the Shapes Test class main() to create, fill, and print a sorted collection of Shapes as a PriorityQueue.

5.       Add code to the Shapes Test class main() to create, fill, and print a sorted collection of Shapes as a TreeMap.  Use the perimeter of the shapes as the key. 

Homework 4:

1.       Enhance the Shapes project to provide a popup window at program start that allows you to pick a music clip (.wav file) from the file system.  You can do this with BlueJ.  A hint - use the JFileChooser class to do most of the work - my implementation is about 15 lines of code (well, maybe 40 if you include the file filter).  There's a Sun tutorial available on using this class.   You may find that trying to play a large wav file (greater than 20 MB or so) causes the debug JVM in BlueJ to run out of heap space.  You can increase the maximum heap space for the debug JVM by adding the -Xmx<size> option to the JVM arguments in the bluej\lib\bluej.defs file.   Find and change the bluj.vm.args property to bluej.vm.args = -server  -Xincgc  -Xmx512m using WordPad or similar text editor.  I used a maximum heap size setting of 512m (512 MB), this value must be a multiple of 1024 bytes. 

2.       Add a class Kite to the Shapes project.  See the MathOpenRef web pages for info on a kite.

3.       Download and install the Eclipse IDE onto your computer.  Alternatively, download and install NetBeans (Sun's full featured IDE) and load up Shapes into it.  There's a BlueJ Edition of NetBeans that is set up to easily accommodate BlueJ projects, or you may choose the latest NetBeans version 6.1.

4.       Move the Shapes project from BlueJ to Eclipse or some version of NetBeans, and rebuild and run it.

Homework 5:

1.       Read chapters 7 (Graphics Programming), 8 (Event Handling), and 9 (Swing) of the text.

2.       Enhance the Shapes project to present a frame that displays the various shapes created in Test.main ().  This isn't very  hard - BlueJ comes with a Shapes demo that does circles, triangles, and squares, so you can at least do these.  The more ambitious of you will try rectangles, parallelograms, trapezoids, and rhomboids.  And I'll really be impressed with anyone implementing ellipse.  Make reasonable assumptions about the allowed size of the objects.

3.       Instrument the Shapes main method to log the start and stop times and the elapsed time of execution.

4.       Enhance the Shapes project to play mp3 files on a background thread.  You can use the JLayer classes from javazoom.

Homework 6:

1.       Read chapters 10 (Deployment) and 11 (Exceptions, Logging, Assertions, and Debugging) of the text.

2.       Enhance the MusicPlayer  project to present a window with an animated graphic of some kind that moves while the music is   playing.

3.       Enhance the MusicPlayer project to allow the selection of multiple files for playback, and play them in sequence or in random (shuffled) order, and to loop on the play list.

Homework 7:

1.       Read chapter 14 (Multithreading) of the text.

2.       Prepare three different UML diagrams (of your choosing) for the MusicPlayer project.  NetBeans will of course generate a complete class diagram for you automatically, so you really only have to figure out how to do two others.

 

Back to top

 

Java Programming Terminology

See how many of these you can define.

Inheritance

Polymorphism

Generic

Inner class

Abstract Class

Concrete Class

Map

Interface

Collection

Thread

Lock

Virtual Machine

Priority

Green Threads

Native Threads

Template

Big Numbers

Static

Scope

Visibility

Extent

Dynamic binding

Static binding

Cast

Protected

Public

private

Signature

Variadic method

Clone

Reference variable

Event

Exception

Frame

Callback

Reflection

Listener

Adapter class

Swing

AWT

Layout

JAR

Sandbox

Assertion

Finally

Tree

Hash set

Runnable

Daemon thread

Race condition

Synchronized

Monitor

Thread pool

Semaphore

Thread-safe

Deadlock

Fatal embrace

Enumeration

Queue

Deque

Supertype

Applet

Object wrapper

Final

Constructor

Superclass

Subclass

Factory method

Main method

Overloading

Package

Class path

Package scope

Object

Class

Object variable

Class variable

Method

Field

Mutator method

Accessor method

String

Immutable

Enumerated type

destructor

OOP

Native method

Stream

File

framework

JVM

JDK

Proxies

Class library

Java Beans

Concurrency

Autobox

 

 

 

Back to top

Last Revised: 11 July  2008
Copyright
Ó 2008 Robert G. Hayes.
e-mail the webmaster: javaclass@earthlink.net

 

provided by florida website design company

Provided by Florida web design firm.

 

Best viewed at 1024x768 16 bit color!
I'm not responsible for your poor resolution!
Pump it up!