This course ended May 11, 2014.

CPSC 124: Introduction to Programming

   Department of Mathematics and Computer Science
   Hobart and William Smith Colleges

   Spring 2014.

   Instructor:  David J. Eck  (

   Course Handout:

   Monday, Wednesday, Friday, 12:20--1:15 PM
       Room Gulick 206A.

   Lab: Tuesday, 1:30--2:55 PM
       Room Gulick 208.

Lab Worksheets
Pre-lab, January 24
Introduction to Linux
Lab 1, January 28
Introduction to Java
Lab 2, February 4
Functions, More I/O, Graphics
Lab 3, February 11
Loops and Branches
Lab 4, February 18
More Control
Lab 5, February 25
Intro to Subroutines
Lab 6, March 4
Eclipse (and Subroutines)
Lab 7, March 11
Arrays, Objects, Events
Lab 8, March 25
Lab 9, April 1
Lab 10, April 8
GUI Tutorial
Lab 11, April 15
Lab 12, April 22
Start Project
Labs 13 and 14, April 29 and May 6: Continue Project

Quizzes and Tests, with Answers
Quiz 1, Jan. 31 Quiz 2, Feb. 7 Quiz 3, Feb. 14 Test 1, Feb. 24
Quiz 4, Mar. 5 Quiz 5, Mar. 12 Quiz 6, Mar. 28 Test 2, Apr. 9
Quiz 7, April 21 Quiz 8, April 28

Some Useful Links

First Week: January 22 and 24

Welcome to the course!

You should begin reading the textbook, which is available on-line at During the first week of the term, we will go over some of the introductory material in Chapter 1 fairly quickly. We will cover only a part of Chapter 1 in class, but it is a good idea to read the entire chapter to get a preview of most of the topics that will be covered during the rest of the semester. However, you should not expect to fully understand everything in Chapter 1 at this time. The most important sections for now are Section 1 and Section 3. Sections 4, 5, and 6 give short overviews of many of the topics that we will cover in the rest of the semester.

On Friday, we will spend part of the class in the Gulick 208 computer lab. This visit will be a "pre-lab" to get you acquainted with the Linux operating system.

The required reading for the first week also includes the course handout.

Second Week: January 27, 29, and 31

The reading for this week is Chapter 2, Section 1 through Section 4. You are responsible for all material in these sections, except for enums (Section 2.3.3) and scanners (Section 2.4.6). There are a lot of details, and only some of them will be discussed in class, so it is important to carefully read the entire assigned material.

The lab on Tuesday is an introduction to Java programming. There is a link to the lab worksheet earlier on this page. It is a good idea to read it before coming to lab. I will not hand out paper copies of lab worksheets.

Computer science teaching assistants will have hours Sunday through Tuesday from 7:00 to 10:00 PM in computer lab in room Lansing 310. My office hours are posted at the top of this page.

Remember that the first quiz is on Friday, January 31, at the start of class! Here are some things that you should know about for the quiz:

        CPU                                     syntax
        fetch-and-execute                       semantics
        main memory                             style
        locations and addresses in memory       variable
        binary numbers                          data type
        machine language                        assignment statement
        high-level language                     javac command
        compiler                                java command

Third Week: February 3, 5, and 7

On Monday, we will be finishing up Section 2.3 and Section 2.4 We will cover subroutines in String objects, formatted output, and comments. On Wednesday, we will talk about some of the operators that are covered in Section 2.5. (Remember that we are not covering enums and Scanner, and we will put off TextIO file I/O for a bit.) This section has a lot of details about various kinds of operators; I will talk about the most important in class. We will not discuss Section 2.6. On Friday, we will move on to Chapter 3. You should read Sections 3.1 and 3.2, although we will not finish 3.2 until next week.

The second quiz is on Friday, February 7. Here are some things that could be on the quiz:

       Writing some Java code to perform a specified task.
       Reading some Java code and saying what it does.
       primitive data types               variable declaration statement
       int                                functions
       double                             Math.sqrt(x)
       char                               Math.pow(x,y)
       boolean                            Math.random()
       true and false                     reading input from the user
       String                             TextIO.getlnInt()
       literals                           TextIO.getlnDouble()
       char literals like 'a', '\''       String functions
       String literals like "Hello"       str.length()
       comments                           str.charAt(i)
       syntax of comments                 str.toUpperCase()

Fourth Week: February 10, 12, and 14

We will continue to work on control structures and algorithm development. By the end of last week, we had covered while loops and basic if statements. We will start this week with some examples, and we will discuss the use of pseudocode to express algorithms. That will finish up Sections 3.1 and 3.2. The new reading for the week is Chapter 3, Sections 3.3 to 3.5, which cover additional control structures (for, multi-way if, and do..while), as well as the break statement.

There will be another quiz this Friday, February 14. It will cover Sections 2.5, 3.1, and 3.2. This includes all the basic Java operators (+, -, *, /, %, ==, !=, <, >, <=, >=, && ||, !, ++, --, +=, -=), type-casting, operator precedence, generating random integers, while loops, if statements, and if-else statements. You should also be familiar with the concepts of pseudocode and step-wise refinement from Section 3.2.

Fifth Week: February 17, 19, and 21

There is no quiz this week, but there is a test coming up next week, on Monday, February 24. The test will cover Chapters 1 through 3. A study guide will be distributed in class on Wednesday.

We will finish up Chapter 3 this week. The new reading is Section 3.7, which introduces exceptions and the try..catch statement. Section 3.8 is an introduction to GUI programming; it is not repart of the reading, but the material in this section has been covered on labs.

We still have to cover "else if" statements more thoroughly, and there are a few loose ends to tie up, including blocks and local variables. I should also mention definite assignment, the continue statement, and labeled break statements, but they might just be left to reading since I will not require you to know them for the test or for lab exercises.

Sixth Week: February 24, 26, and 28

There is a test on Monday, February 24. Here is the study guide. And here are the sample solutions.

On Wednesday, we will start Chapter 4, which covers writing and using subroutines. It also covers global variables, that is, variables that are declared outside any subroutine. Note that subroutines in Java are also called methods, and I will start using the term method as a synonym for subroutine. The reading for the week is Sections 4.1 and 4.2.

Because of the test on Monday, I will not collect Lab 4 until Thursday morning.

Seventh Week: March 3, 5, and 7

We will continue with Chapter 4 and with subroutines. The reading for the week is Sections 4.3 to 4.6, although we might not complete 4.6 until next week. You will find that we have already covered some of the material in 4.3 through 4.5.

The lab this week will introduce the Eclipse Integrated Development Environment. Although it is a big complex system, you will find that it will help you be a more productive programmer in many ways.

There is a quiz on Wednesday of this week, covering mainly Sections 4.1 and 4.2. You should expect to be asked to write at least one complete subroutine. Other things that could be on the quiz include:

          black box,  interface,  implementation
          subroutine,  method,  calling a subroutine
          dummy parameter,  actual parameter
          function,  return type,  void
          access modifier,  public and private

Eighth Week: March 10, 12, and 14

We will finish Chapter 4 this week and move on to the first section of Chapter 5. The reading is Sections 4.7 and 5.1. Next week is Spring break. After break, we are going to depart from the original schedule on the syllabus to cover some of the basic material about arrays. In fact, this week's lab already introduces arrays.

There is a quiz on Wednesday this week. You should expect to be asked another complete subroutine. New ideas for the quiz include: Javadoc, software toolboxes, APIs, packages, and top-down and bottom-up design and how they use subroutines.

Ninth Week: March 24, 26, and 28

We will review the part of Section 5.1 that was covered on the Friday before break. We will finish that section and cover Section 5.2. These two sections are an introduction to the basics of creating and using objects. After that, we will spend a little time with arrays, covering Section 7.1, Subsection 7.5.1, and Subsection 7.5.2 by next Monday.

There is a quiz on Friday of this week. It will cover Sections 4.7 and 5.1. Some important terms and ideas include:

            combining initialization with declaration
            the "final" modifier
            named constants and reasons for using them
            scope of variables
            objects and how they relate to classes
            instance variables and instance methods
            static versus non-static 
            creating objects with the "new" operator
            pointers and their implications for assignment and comparison
            the heap

Tenth Week: March 31; April 2 and 4

The next test is coming up on Wednesday of next week, April 9. There is no quiz this week.

We will spend some more time on the basics of arrays. After that, we return to Chapter 5 to continue our discussion of objects and object-oriented programming. The reading for the week is Section 5.3 and Section 5.4. This is the last reading that will be covered on next week's test.

Eleventh Week: April 7, 9, and 11

There is a test on Wednesday of this week, April 9. Here is the study guide.

As for new material for this week, we will work on Section 5.5. This section covers subclasses, inheritance, and polymorphism, which are the true heart of object-oriented programming.

Twelfth Week: April 14, 16, and 18

We will spend most of the week working on Chapter 5. We have just begun Section 5.5. We will continue with that section and then move on to some selected topics from Sections 5.6 and 5.7. Sections 5.6 covers the special variables this and super. We have already used this informally, but super is new. The important ideas in Section 5.7 include interfaces, implementing interfaces, and nested classes, and you should concentrate on 5.7.1 and 5.7.2.

The lab this week is about making subclasses of existing classes and using an API.

Note that the sample answers to last week's test are available.

Thirteenth Week: April 21, 23, and 25

There is a quiz on Monday, April 21. It will cover Sections 5.5 and 5.6. Here are some terms and topics that could be on the quiz:

      extending a class        assignment rules for subclasses
      subclass                 type-casting for classes
      superclass               the instanceof operator
      inheritance              protected
      abstract class           the special variables this and super
      class hierarchy          overriding an instance method in a subclass

For the final three labs in the course, you will work on a final project, either Hangman or some other program that you propose and for which you get my approval. After the quiz on Monday, we will spend most of the day talking abou Hangman and going over some of the new material from Chapter 6 that you will need to complete the lab on Tuesday. On Wednesday and Friday, we will continue with selected topics from Chapter 6.

Fourteenth Week: April 28 and 30; May 2

The final quiz of the semester is on Monday, April 28. It will cover the basic ideas of GUI programming that we have been looking at in class. Terms and ideas include:

     components, JButton, JLabel, JTextField, JPanel,
     layout, layout manager, BorderLayout, GridLayout,
     adding a component to a panel, using a panel as a "display",
     listeners and events, ActionListener

After finishing what I have to say about GUI programming, we will return to Chapter 7 for a more in-depth look at arrays, including searching, sorting, and ArrayList. You should read the parts of Chapter 7 that you have not yet read. In particular, you should read 7.1.3, 7.2.4, 7.3.1, 7.3.2, 7.3.3, and all of 7.4.

End of Classes and Final Exam: May 5 and 11.

The last day of class in Monday, May 5. We will spend the day wrapping up the course and reviewing for the final exam. There is a final exam on Tuesday, May 6, but you can spend it working on your final project. The final exam is at the officially scheduled time: Sunday, May 11, at 7:00 PM. It will be given in our regular classroom.

The last day for turning in your final project and any extra programs that you have written is Monday, May 12, the day after the final exam.

Study guide for the final exam.

   End-of-semester office Hours in Lansing 313 (but also look for me in Lansing 310):
         Tuesday, May 6:   12:00 – 1:20 PM
         Thursday, May 8:   2:00 – 4:00 PM
         Friday, May 9:     1:00 – 3:00 PM
         Saturday, May 10: 11:00 AM – 2:00 PM
         Sunday, May 11:   12:00 – 1:15 PM and 6:00 – 6:45 PM