Introduction to Computer Science using Java

Revised and Expanded, July 2003

Bradley Kjell, Central Connecticut State University

This is a first course in Computer Science using the programming language Java. It covers the fundamentals of programming and of computer science.

For maximum benefit, go though these notes interactively, thinking about and answering the question at the bottom of each page. There are about 15 pages per chapter. If you spend about 3 minutes per page each chapter will take about 45 minutes; much more, if you copy and run some of the programs. If you are a beginning programmer, plan on spending more than a month with this.

These notes assume that you have the Java Development Kit (JDK) version 1.3 or later from Sun (http://www.javasoft.com) and a text editor such as NotePad. They may be used with more sophisticated environments, as well. For more about these notes check the frequently asked questions.

Best viewed at 800 x 600

Part 1: Hardware and Software

General computer science topics. Hardware and software. Analog and binary signals. Machine language and high level languages. Language translation and interpretation.

 
  Chapter 1 Introduction to Computer Systems Quiz Flash Cards.
  Chapter 2 Analog and Binary Signals Quiz Flash Cards.
  Chapter 3 Computer Memory Quiz Flash Cards.
  Chapter 4 The Processor Quiz Flash Cards.
         

Part 2: Running Java Programs

How to run Java programs. Translating Java source code into bytecodes. How bytecodes are interpreted. How to create a Java program.

 
  Chapter 5 Introduction to Java Review.  
  Chapter 6 Small Java Programs Review.  
  Chapter 7 How to Run the Example Programs Review.  
         

Part 3: Java Programming

How to program in Java.

 
  Chapter 8 Primitive Data Types Quiz Programming Exercises
        Flash Cards
  Chapter 9A Variables and the Assignment Statement Quiz Programming Exercises  
  Chapter 9B Expressions and Arithmetic Operators Quiz Programming Exercises  
  Chapter 10 Input and Output Review Programming Exercises  
  Chapter 11 Floating Point Input Review Programming Exercises  
  Chapter 12 The if Statement Quiz Programming Exercises  
  Chapter 13 The Single Branch if Statement Quiz Programming Exercises  
  Chapter 14 Boolean Expressions Review Programming Exercises  
  Chapter 15 Loops and the while statement Review Programming Exercises  
  Chapter 16 Counting Loops Quiz Programming Exercises  
  Chapter 17 Examples of Counting Loops Review Programming Exercises  
  Chapter 18 Sentinel-controlled Loops Review Programming Exercises  
  Chapter 19 Result-controlled Loops Quiz Programming Exercises  
  Chapter 20 Example Program -- Combination Lock Review Programming Exercises  
  Chapter 21 File Input and Output Review Programming Exercises  
  Chapter 22 Reading Data from a File Review Programming Exercises  
  Chapter 23 File Input Techniques   Programming Exercises  
         

Part 4: Object Oriented Programming

Object Oriented programming. Software objects.

 
  Chapter 25  Objects Quiz  
  Chapter 26 Object References Quiz  
  Chapter 27 More about Objects and Classes Review  
  Chapter 28 Method Parameters Review  
  Chapter 29 Strings and Object References Quiz Programming Exercises
  Chapter 30 Defining your own Classes Review     Programming Exercises
  Chapter 31 Class Design Example (miles per gallon) Review Programming Exercises
  Chapter 32 Class Design Example (checking account) Review  
  Chapter 33 Encapsulation and Visibility Modifiers Quiz Programming Exercises
  Chapter 34A Parameters, Overloading, Local Variables Review  
  Chapter 34B Object Parameters Quiz  
  Chapter 35 Objects that Contain Objects Review Programming Exercises
         

Part 5: Applets and Graphics

  Chapter 36  Applets Quiz     Programming Exercises
  Chapter 37  Applet Examples Quiz Programming Exercises
  Chapter 38  More Applet Examples Quiz Programming Exercises
 

Part 6: More Java Programming Features

Incrementing and decrementing variables. Convenient ways to create loops.

 
  Chapter 39  Increment, Decrement, and Assignment Operators Quiz      
  Chapter 40  Boolean Expressions and Short-circuit Operators Review      
  Chapter 41  The for Statement Quiz     Programming Exercises
  Chapter 42  More about the for Statement Quiz     Programming Exercises
  Chapter 43  The Conditional Operator, and the switch Statement Quiz     Programming Exercises
  Chapter 44  The do Statement Quiz     Programming Exercises
  Chapter 46  Introduction to Arrays Quiz     Programming Exercises
  Chapter 47  Common Array Algorithms Quiz     Programming Exercises
  Chapter 48  Arrays as Parameters Review      
  Chapter 49A  Methods that Change Arrays Quiz      
  Chapter 49B  Arrays of Objects and Linear Search Quiz     Programming Exercises
  Chapter 49C  Two-dimensional Arrays Quiz     Programming Exercises
  Chapter 49D  StringBuffers and StringTokenizers Quiz     Programming Exercises
 

Part 7: Advanced Object Oriented Programming

Advanced features of object oriented programming.

 
  Chapter 50  Introduction to Inheritance Quiz      
  Chapter 51  Abstract Classes and Polymorphism Quiz      
  Chapter 52  More about Polymorphism Quiz      
  Chapter 53  Interfaces Quiz      
  Chapter 54  Vectors and Enumerations Quiz      
 

Part 8: Graphical User Interface Programming

Graphical user interfaces. Project Swing and the Abstract Windowing Toolkit.

 
  Chapter 55  Introduction to GUI Programming Quiz      
  Chapter 56  Swing Frames Quiz      
  Chapter 57  Event Listeners Quiz      
  Chapter 58  Adding Buttons to a Frame Quiz Programming Exercises
  Chapter 59 Buttons and Action Events Quiz     Programming Exercises    
  Chapter 60  Swing Text Fields and Labels Quiz     Programming Exercises    
  Chapter 61  Components Layout Quiz     Programming Exercises    
  Chapter 62  JPanel and BoxLayout    
  Chapter 63  Radio Buttons and BorderLayout   Programming Exercises    
  Chapter 64  Sliders and Change Events   Programming Exercises    
 

Part 9: Recursion

Recursion in problems, recursion in Java, recursion in graphics.

 
  Chapter 70  Introduction to Recursion Quiz      
  Chapter 71  Recursion in Java Quiz     Programming Exercises
  Chapter 72  Examples of Recursion Quiz     Programming Exercises
  Chapter 73  More Recursion Quiz     Programming Exercises
  Chapter 74  Recursion with Graphics     Programming Exercises
 

Part 10: Exceptions and IO Streams

Exceptions. Disk file input and output.

 
  Chapter 80  Exceptions and Errors Quiz     Programming Exercises
  Chapter 81  More about Exceptions Quiz     Programming Exercises
  Chapter 82  Input and Output Streams Quiz        
  Chapter 83  Writing Text Files Quiz     Programming Exercises
  Chapter 84  Reading Text Files Quiz     Programming Exercises
  Chapter 85  Writing Binary Files Quiz     Programming Exercises
  Chapter 86  Reading Binary Files Quiz     Programming Exercises
  Chapter 87  The File Class Quiz     Programming Exercises

Appendix

Index