Introduction to Computer Science using Java

Bradley Kjell, Central Connecticut State University

This is a course in Java programming for beginners. It covers the fundamentals of programming, roughly the same material that is covered in a beginning programming course in a university or in a high school AP Computer Science course.

A more recent version of this material is here: Mirror Site This more recent version omits some material that has been deprecated in Java 9

For maximum benefit, go though these notes interactively, thinking about and answering the question at the bottom of each page. There are about 20 pages per chapter. If you spend about 3 minutes per page each chapter will take about 60 minutes, or longer 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 a recent version of Java, available from Oracle, Inc. at

and a text editor such as Notepad. Compiling and running programs is done from the command line interface. You may use more sophisticated environments, as well.


For more about these notes check the frequently asked questions.

A German translation of these notes, done by Heinrich Gailer, is available at

A French translation of selected chapters is available at

The web site lets you copy-and-paste Java code into a web page text box, then compile and run it completely within your browser.

This site also allows you to practice Java programming on line:

Another nice site that allows you to run Java programs directly in your browser is:

Part 1: Hardware and Software

      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

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

Part 3: Data

  Chapter 8 Primitive Data Quiz Exercises and Flash Cards
  Chapter 9A Variables and the Assignment Statement Quiz Exercises
  Chapter 9B Expressions and Arithmetic Operators Quiz Exercises
  Chapter 9C Object Data Quiz Exercises
  Chapter 10 Input and Output Review Exercises
  Chapter 11 Floating Point Review Exercises

Part 4: Branches and Loops

  Chapter 12 The if Statement Quiz Exercises
  Chapter 13 The Single Branch if Statement Quiz Exercises
  Chapter 14 Boolean Expressions Review Exercises
  Chapter 15 Loops and the while statement Review Exercises
  Chapter 16 Counting Loops Quiz Exercises
  Chapter 17 Nesting Loops and Ifs Review Exercises
  Chapter 18 Sentinel-controlled Loops Review Exercises
  Chapter 19 Result-controlled Loops Quiz Exercises
  Chapter 20 Random Quiz Exercises and Review

Part 5: File Input and Output

  Chapter 21 Files and File Redirection Review Exercises
  Chapter 22 Reading Data with File Redirection Review Exercises
  Chapter 23 I/O using Scanner and PrintStream Review Exercises
  Chapter 24 File Input Techniques Review Exercises
  Chapter 24B Formatted Output Quiz Exercises

Part 6: Object Oriented Programming

  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 Exercises
  Chapter 29B More about Strings Quiz Exercises
  Chapter 30 Defining your own Classes Review     Exercises
  Chapter 31 Class Design Example (miles per gallon) Review Exercises
  Chapter 32 Class Design Example (checking account) Review  
  Chapter 33 Encapsulation and Visibility Modifiers Quiz Exercises
  Chapter 34A Parameters, Overloading, Local Variables Review  
  Chapter 34B Object Parameters Quiz  
  Chapter 35 Objects that Contain Objects Review Exercises

Part 7: Graphics

  Chapter 36  Beginning Graphics Quiz     Exercises
  Chapter 37  Graphics Examples Quiz Exercises

Part 8: More Java Features

  Chapter 39  Increment, Decrement, and Assignment Operators Quiz      
  Chapter 40  Boolean Expressions and Short-circuit Operators Quiz      
  Chapter 40B  Truth Tables and De Morgan's Laws Review      
  Chapter 41  The for Statement Quiz     Exercises
  Chapter 42  More about the for Statement Quiz     Exercises
  Chapter 43  The Conditional Operator and the switch Statement Quiz     Exercises
  Chapter 44  The do Statement Quiz     Exercises

Part 9: Arrays

  Chapter 46  Introduction to Arrays Quiz     Exercises
  Chapter 47  Common Array Algorithms Quiz     Exercises
  Chapter 48  Arrays as Parameters Review     Exercises
  Chapter 49A  Methods that Change Arrays Quiz      
  Chapter 49B  Arrays of Objects and Linear Search Quiz     Exercises
  Chapter 49C  Two-dimensional Arrays Quiz     Exercises
  Chapter 49D  StringBuffers Quiz     Exercises

Part 10: Advanced 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     Exercises
  Chapter 53B  The Comparable Interface Quiz     Exercises
  Chapter 54  ArrayLists and Iterators Quiz      

Part 11: Graphical User Interface Programming

  Chapter 55  Introduction to GUI Programming Quiz      
  Chapter 56  JFrames Quiz      
  Chapter 57  Adding Buttons to a Frame Quiz      
  Chapter 59 Buttons and Action Events Quiz     Exercises    
  Chapter 60  JTextFields and JLabels Quiz     Exercises    
  Chapter 61  GUI Applications Quiz     Exercises    
  Chapter 62  JPanel and BoxLayout Quiz      
  Chapter 63  Radio Buttons and BorderLayout   Exercises    
  Chapter 64  JSliders and Change Events   Exercises    

Part 12: Recursion

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

Part 13: Exceptions and IO Streams

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

Part 14: Sorting and Searching

  Chapter 90  Selection Sort with Integers Exercises    
  Chapter 91  Insertion Sort with Integers Exercises    
  Chapter 92  Sorting Arrays of Objects and class Arrays        
  Chapter 100   Beginning Linked Lists        
  Chapter 101   Linked Lists Exercises    


  Index     Book-like index for these Java notes.      

Search this site with Enter your search terms:

Creative Commons License
Introduction to Computer Science using Java by Bradley Kjell is licensed under a Creative Commons Attribution-NonCommercial 3.0 Unported License.