Code Examples and Reading Assignments

This page documents what we do in class. It contains Java programs that we will discuss in class, simple homework exercises that you can work on for practice and exam preparation (not for credit), and reading assignments from our textbook.

The reading assignments and practice problems are listed by the date on which they were assigned. The sample program files are listed by the date on which they were used. You can click on either a .java link and see the source code, or click on a .html link (when available) and see an applet running. When you are viewing the source code, you can use your browser's "File -> Save As..." menu item to save a copy of the file on your computer. It is a good idea for you to "play" with these example programs; compile them, run them, make simple changes to them and compile and run them again.

  • Wednesday, December 3.
    • The final exam for this course is at 1:00 on Monday, December 8. The final exam will be over the whole semester. To study for the exam, look at the first two exams and also go over the problems that were assigned at the ends of the chapters covered by those two exams. Since the second exam we have covered chapters 7 and 9. Only Chapter 7 will be on the final.
    • Remember to see the homework page for your last programming assignment.
    • Here is a simple outline of the Java GUI framework.
    • The following program shows one way to implement the GUI described by this image. The program does not implement any functionality at all, it only implements the appearance of the GUI.
    • The following program demonstrates almost all of the different kinds of events that Java GUI components can generate. This program is also itself an example of a moderately complex GUI.

  • Monday, December 1.
    • See the homework page for your last programming assignment.
    • A demonstration of polymorphism and casting.
    • This program demonstrates a rather surprising consequence of polymorphism.
    • For Wednesday, read Sections 9.3-9.6 (pages 528-562) from the textbook.

  • Wednesday, November 26.

  • Monday, November 24.

  • Wednesday, November 19.
    • See the homework page for your new programming assignment.
    • For Monday, read Section 7.4 (pages 406-419) from the textbook.

  • Monday, November 17.
    • For Wednesday, read Sections 7.1-7.3 (pages 391-406) from the textbook.

  • Wednesday, November 12.
    • See the homework page for your new programming assignment.
    • For Monday, read Sections 6.5-6.6 (pages 359-371) and Section 7.0 (pages 382-391) from the textbook.

  • Monday, November 10.
    • Remember that the second midterm exam for this course will be on Wednesday. The exam will be over Chapter 4, Chapter 5 (except Section 5.3), and Sections 6.0, 6.1, and 6.3 from Chapter 6.
    • A demonstration of "ragged arrays".

  • Wednesday, November 5.
    • If you want to try using BlueJ it is easy to install it on your computer.
      • Download the BlueJ installer for Windows. Just run the installer and it should install BlueJ without any trouble.
      • Here is a good, brief, BlueJ tutorial to help you get started.
      • If you are interested in learning more about BlueJ, go to the BlueJ documentation page and download the reference manual and the tutorial.

  • Monday, November 3.
    • See the homework page for your next programming assignment.
    • The second midterm exam for this course will be on Wednesday, November 12.
    • For Wednesday, read part of Section 6.2 (pages 339-346), Section 6.3 (pages 350-355), and Sections 6.5-6.6 (pages 359-371) from the textbook.
    • Do Exercises 6.5, 6.6, and 6.8 from page 374-375.

  • Wednesday, October 29.
    • Here is a version of the PushButton applet with the ButtonListener class outside of the applet class. This becomes kind of awkward, and shows why inner classes can be useful.
    • For Monday, read Sections 6.0 and 6.1 (pages 320-339) from the textbook.
    • Do Exercises 6.1, 6.3, and 6.4 from page 374.

  • Wednesday, October 22.

  • Monday, October 20.

  • Wednesday, October 15.
    • See the homework page for your seventh programming assignment.
    • For Monday, read Sections 5.0-5.3 (pages 270-290) from the textbook.
    • Do Exercises 5.1 and 5.2 at the end of Chapter 5 (page 314).

  • Monday, October 13.
    • For Wednesday, read Sections 4.5, 4.6, and 4.7 (pages 243-260) from the textbook.
    • Do Exercises 4.19, 4.20-4.23, 4.24-4.25, and 4.27 at the end of Chapter 4 (pages 262-264).

  • Wednesday, October 8.
    • See the homework page for your sixth programming assignment.
    • Here is an example that modifies the Coin class from Section 4.1 by adding a method to check if two coins have the same face.
    • Here is an example that modifies the Coin class from Section 4.1 by changing the implementation of the class without changing the interface of the class.
    • For Monday, read Sections 4.3 and 4.4 (pages 233-242) from the textbook.
    • Do Exercises 4.1, 4.2, 4.4, 4.5, 4.7, and 4.9-4.11 at the end of Chapter 4 (pages 262-264).

  • Monday, October 6.
    • For Wednesday, read Sections 4.0, 4.1, and 4.2 (pages 210-233) from the textbook.

  • Monday, September 29.
    • Remember that the first midterm exam is this Wednesday. The exam will cover Chapters 1, 2, and 3 from the textbook. To prepare for the exam, do the assigned homework exercises from the end of each chapter.
    • See the homework page for your fifth programming assignment.

  • Wednesday, September 24.
    • Recall that the first midterm exam is next Wednesday, Oct. 1. The exam will cover Chapters 1, 2, and 3 from the textbook. To prepare for the exam, do the assigned homework exercises from the end of each chapter.
    • Here is a problem that demonstrate a more complex example of nested while-loops than what is in Section 3.6 of our textbook. The different versions show how we might refactor a program to improve it.
    • Here are two example programs that modify one of the for-loop examples from Section 3.6.

  • Monday, September 22.
    • For Wednesday, read Sections 1.5 (pages 47-49), 2.10-2.11 (pages 106-117), and 3.10 (pages 188-195).
    • Do Exercises 2.16, 2.17, 2.18, and 2.19 at the end of Chapter 2 (pages 122-123).

  • Wednesday, September 17.
    • See the homework page for your fourth programming assignment.
    • Here are two example programs that demonstrate an important idea about nested if-statements.
    • For next Monday, read Section 3.8 (pages 177-183).
    • Do Exercises 3.10, 3.11, 3.13, 3.18, 3.19, and 3.20 at the end of Chapter 3 (pages 199-200).

  • Monday, September 15.
    • For Wednesday, read Sections 3.5-3.7 (pages 153-176).
    • Do Exercises 3.8, 3.9, 3.12, 3.14, 3.15, 3.16, and 3.17 at the end of Chapter 3 (pages 199-200).

  • Wednesday, September 10.
    • See the homework page for your third programming assignment.
    • For today, we will continue to go over ideas from Sections 2.6, 2.7 and 2.8. We will not go over in class the material from Section 2.9 since we will not be making much use of it later in the course.
    • For next Monday, read Sections 3.0-3.4 (pages 130-153).
    • Do Exercises 3.1, 3.3, 3.4, 3.5, 3.6, and 3.7 at the end of Chapter 3 (pages 198-199).

  • Monday, September 8.
    • We will do some examples today using an interactive version of Java call BeanShell. Putting Beanshell on a computer is very easy.
      • Download Beanshell (Note: This is not an installer. This is the actual BeanShell program.)
      • The program that you just downloaded is call an "executable jar file". If you have the Java JDK 1.4.1 installed properly on your computer, all you have to do to run BeanShell is double click in this jar file. You can store the jar file anywhere you like.

  • Wednesday, September 3.
    • See the homework page for your second programming assignment.
    • For next Monday, read Sections 2.6-2.9 (pages 87-106) from the textbook.
    • Do Exercises 2.12, 2.13, and 2.14 at the end of Chapter 2 (page 122). These are problems about the material in sections 2.6-2.9.

  • Wednesday, August 27.
    • Remember to see the homework page for your first programming assignment.
    • For next week, read Sections 2.0-2.5 (pages 62-87) from the textbook.
    • Do Exercises 2.1-2.10 at the end of Chapter 2 (pages 120-121). These are problems about the material in sections 2.1-2.5.

  • Monday, August 25.
    • Read all of Chapter 1, but our main emphasis will be on Sections 1.3, 1.4, and 1.5.
    • Do Exercises 1.15-1.22 at the end of Chapter 1 (pages 55-56).
    • Here is a template for writing simple Java programs.


Return to the main Java page.
Return to the CS 123 home page.


compliments and criticisms