316 courses ePortfolio Forums Blog FAQ

Introduction to Computer Science I

Purpose of Course  showclose

This course will introduce students to the field of computer science and the fundamentals of computer programming.  It has been specifically designed for students with no prior programming experience, and does not require a background in Computer Science.  This course will touch upon a variety of fundamental topics within the field of Computer Science and will use Java, a high-level, portable, and well-constructed computer programming language developed by Sun Microsystems, to demonstrate those principles.  We will begin with an overview of the topics we will cover this semester and a brief history of software development.  We will then learn about Object-Oriented programming, the paradigm in which Java was constructed, before discussing Java, its fundamentals, relational operators, control statements, and Java I/0.  The course will conclude with an introduction to algorithmic design.  By the end of the course, you should have a strong understanding of the fundamentals of Computer Science and the Java programming language.  This course will lay the groundwork for a strong educational experience in Computer Science and a successful career devoted to implementing the principles you will learn as you progress through the CS major.

Course Requirements  showclose

In order to take this course you must:
 
√    Have access to a computer.
 
√    Have continuous broadband Internet access.
 
√    Have the ability/permission to install plug-ins or software (e.g., Adobe Reader or Flash).
 
√    Have the ability to download and save files and documents to a computer.
 
√    Have the ability to open Microsoft files and documents (.doc, .ppt, .xls, etc.).
 
√    Be competent in the English language.
     
√    Have read the Saylor Student Handbook.

Unit Outline show close


Expand All Resources Collapse All Resources
  • Unit 1: Introduction  

    We will begin this course by identifying our motivation for learning fundamental programming concepts and learning the history of programming languages in general.  We will then discuss the hardware (the physical devices that make up the computer) and software (Operating Systems and applications that run on the computer) of a computer.  We will conclude with a brief discussion of the Java programming language, which we will use throughout the rest of this course.  By the end of this unit, you will have a strong understanding of the history of programming and be well prepared to learn about programming concepts in greater detail.

    Unit 1 Time Advisory   show close
    Unit 1 Learning Outcomes   show close
  • 1.1 History and Motivation  
  • 1.1.1 History of Software and Computer System Design  
  • 1.1.2 Evolution of Programming  
  • 1.2 Hardware/Software Model of a Computer  
  • 1.2.1 Hardware vs. Software  
    • Reading: Central Connecticut State University: Bradley Kjell’s Introduction to Computer Science Using Java: “Chapter 1: Introduction to Computer Systems”

      Link: Central Connecticut State University: Bradley Kjell’s Introduction to Computer Science Using Java: “Chapter 1: Introduction to Computer Systems” (PDF)
       
      Instructions: Please review the notes for Chapter 1.  For maximum benefit, go through these notes interactively, thinking about and answering the questions at the bottom of each page. 

      These notes are an experiment in applying the “programmed learning” method to web-based computer aided instruction.  The subject is Java Programming for beginning programmers.  The content is intended to start beginning programmers out on the track to professional-level programming and reinforce learning by providing abundant feedback.

      Studying this chapter should take approximately 2 hours.

      Terms of Use: This resource has been reposted with the kind permission of Bradley Kjell, and the original version can be found here (HTML or MP3). Please note that this material is under copyright and cannot be reproduced in any capacity without the explicit permission from the copyright holder.

    • Assessment: Central Connecticut State University: Bradley Kjell’s Introduction to Computer Science Using Java: “Quiz for Chapter 1”

      Link: Central Connecticut State University: Bradley Kjell’s Introduction to Computer Science Using Java:Quiz for Chapter 1” (PDF)
       
      Instructions: Please complete the multiple-choice quiz. 
       
      Completing this assessment should take approximately 30 minutes.
       
      Terms of Use: This resource has been reposted with the kind permission of Bradley Kjell, and the original version can be found here (HTML). Please note that this material is under copyright and cannot be reproduced in any capacity without the explicit permission from the copyright holder.

  • 1.2.2 Programs and Processes  
    • Web Media: Khan Academy’s “Binary Numbers”

      Link: Khan Academy’s “Binary Numbers” (YouTube)

      Instructions: Please watch this lecture on Binary Numbers, which are used to represent numbers in computer memory.  In fact, all types of information, not just numbers, but characters as well, are stored in memory using binary bits (i.e. digits) of 0 and 1.  We still write numbers in our programs using decimal numbers, but the interpreter converts them to binary when it interprets them for execution as part of a machine language instruction (the interpreter interprets the Java or Python statement to equivalent, i.e. same semantics, machine language statements).  If you are familiar with and understand the concepts of base 10 radix (decimal number system) and base 2 radix (binary number system), you may skip this lecture. 
       
      Watching the lecture and taking notes should take approximately 15 minutes.

      Terms of Use: Please respect the copyright and terms of use displayed on the webpage above.

    • Reading: Central Connecticut State University: Bradley Kjell’s Introduction to Computer Science Using Java: “Chapter 4: The Processor”

      Link: Central Connecticut State University: Bradley Kjell’s Introduction to Computer Science Using Java:Chapter 4: The Processor” (PDF)
       
      Instructions: Please review the notes for Chapter 4.  As you work through the notes, think about and answer the questions at the bottom of each page. 
       
      Reading this chapter should take approximately 2 hours.
       
      Terms of Use: This resource has been reposted with the kind permission of Bradley Kjell, and the original version can be found here (HTML or MP3).  Please note that this material is under copyright and cannot be reproduced in any capacity without the explicit permission from the copyright holder. 

    • Assessment: Central Connecticut State University: Bradley Kjell’s Introduction to Computer Science Using Java: “Quiz for Chapter 4”

      Link: Central Connecticut State University: Bradley Kjell’s Introduction to Computer Science Using Java: “Quiz for Chapter 4” (PDF)
       
      Instructions: Please complete the multiple-choice quiz. 
       
      Completing this assessment should take approximately 30 minutes.
       
      Terms of Use: This resource has been reposted with the kind permission of Bradley Kjell, and the original version can be found here (HTML or MP3).  Please note that this material is under copyright and cannot be reproduced in any capacity without the explicit permission from the copyright holder.

      The Saylor Foundation does not yet have materials for this portion of the course. If you are interested in contributing your content to fill this gap or aware of a resource that could be used here, please submit it here.

      Submit Materials

  • 1.2.3 The Programming Lifecycle  
  • 1.2.3.1 Concept  
  • 1.2.3.2 Planning and Analysis  

    Note: This topic is covered by the reading in subunit 1.2.3.1.

  • 1.2.3.3 Design  

    Note: This topic is covered by the reading in subunit 1.2.3.1.

  • 1.2.3.4 Implementation  

    Note: This topic is covered by the reading in subunit 1.2.3.1.

  • 1.2.3.5 Testing and Debugging  

    Note: This topic is covered by the reading in subunit 1.2.3.1.

  • 1.2.3.6 Deployment  

    Note: This topic is covered by the reading in subunit 1.2.3.1.

  • 1.2.3.7 Maintenance  

    Note: This topic is covered by the reading in subunit 1.2.3.1.

  • 1.3 Java  
  • 1.3.1 The History of Java Programming Language  
  • 1.3.2 High vs. Low Level Programming Languages  
  • 1.3.3 Interpreted vs. Compiled Languages  
  • 1.3.4 Byte Code vs. Machine Code  
  • 1.3.5 Compiling and Running a Simple Java Program  
  • 1.3.5.1 Downloading and Installing Java Development Kit (JDK)  
    • Reading: Nanyang Technological University’s “Downloading and Installing JDK”

      Link: Nanyang Technological University’s “Downloading and Installing JDK” (HTML)
       
      Instructions: Please use the above link to download and install the latest version of JDK.  After installing JDK, read the instructions carefully to set the “classpath” mentioned in Step 3.  Once JDK has been installed, you can write a simple Java program using an editor such as notepad and run it from a command prompt.  Alternatively, Java programs can be written using an Integrated Development Environment (IDE) such as NetBeans.  Please see the next subunit for information on downloading and installing NetBeans.
       
      Completing this process should take approximately 1 hour.
       
      Terms of Use: Please respect the copyright and terms of use displayed on the webpage above. 

  • 1.3.5.2 Installing NetBeans (IDE)  
    • Reading: Nanyang Technological University’s “Downloading and Installing NetBeans IDE”

      Link: Nanyang Technological University’s “Downloading and Installing NetBeans IDE” (HTML)
       
      Instructions: Please follow the instructions on the webpage to download and install NetBeans, a commonly used IDE for Java programming.  After installing NetBeans, use instructions in Step 2 to write a simple Java program called “Hello.java.”  Please write this program using NetBeans and then compile and run it.
       
      Completing this process should take approximately 1 hour.
       
      Terms of Use: Please respect the copyright and terms of use displayed on the webpage above. 

  • 1.3.5.3 Java Application Programming Interface (API)  
  • Unit 2: Object-Oriented Programming  

    Java is an Object-Oriented programming language.  Since Object-Oriented programming (OO) is currently one of the most popular programming paradigms, you will need to learn its fundamental concepts in order to build a career in Computer Science.  This unit will begin with a discussion of what makes OO programming so unique, and why its advantages have made it the industry-standard paradigm for newly-designed programs.  We will then discuss the fundamental concepts of OO and relate them back to Java.  By the end of this unit, you will have a strong understanding of what Object-Oriented programming is, how it relates to Java, and why it is employed.

    Unit 2 Time Advisory   show close
    Unit 2 Learning Outcomes   show close
  • 2.1 Programming Language Design  
  • 2.1.1 Object-Oriented vs. Procedural  
  • 2.1.2 Advantages/Disadvantages of OO Programming  
  • 2.1.3 Examples  
  • 2.1.3.1 Java  
    • Reading: Oracle’s The Java Tutorials: “What Is a Class?”

      Link: Oracle’s The Java Tutorials: “What Is a Class?” (HTML)

      Instructions: Please read this article.  The Java Tutorials are practical guides for programmers who want to use the Java programming language to create applications.  They include hundreds of complete, working examples, and dozens of lessons.  Groups of related lessons are organized into “trails.”  This tutorial from Oracle gives an overview of a class in Java.

      Reading this article should take approximately 15 minutes.

      Terms of Use: Please respect the copyright and terms of use displayed on the webpage above.

  • 2.1.3.2 Python  
  • 2.1.3.3 C++  
  • 2.2 Fundamental Concepts of OO Programming  
  • 2.2.1 Classes vs. Objects  

    Note: Please pay special attention to the last section on the page to understand classes and objects.

  • 2.2.2 Inheritance  

    Note: Please pay special attention to the last section on the page to understand the concept of inheritance.

  • 2.2.3 Encapsulation  

    Note: Please pay special attention to the second section of the resource to understand the concept of encapsulation.

  • 2.2.4 Polymorphism  
  • 2.2.5 Decoupling  
  • Unit 3: Java Fundamentals  

    Now that you have a basic understanding of OO programming, we will move on to the fundamental concepts of the programming language we will be studying this semester: Java.  The Java-related concepts you will learn in this unit are in many cases directly transferable to a number of other languages.  We will begin by learning about “Hello World,” a basic software application that simply prints “Hello World” to the screen as a means of demonstrating the most essential elements of a programming language, and then move on to discuss the more fundamental concepts of variables, literals, data types, and operators.  In addition, we will also learn about two different styles of adding comments to the code.  By the end of this unit, you should have a fundamental understanding of Java basics and be prepared to utilize those concepts later in the course.

    Unit 3 Time Advisory   show close
    Unit 3 Learning Outcomes   show close
  • 3.1 HelloWorld.java  
  • 3.1.1 Class and File Naming Conventions  
    • Reading: Central Connecticut State University: Bradley Kjell’s Introduction to Computer Science Using Java: “Chapter 6: Small Java Programs”

      Link: Central Connecticut State University: Bradley Kjell’s Introduction to Computer Science Using Java: “Chapter 6: Small Java Programs” (PDF)

      Instructions: Please read through the first three pages of this chapter.  These three pages discuss the naming conventions as well as the reserved words in Java programming language.  If you wrote the Hello.java program as mentioned in sub-subunit 1.3.5.2, then this section might be a little review for you.

      Reading these screens should take approximately 15 minutes.

      Terms of Use: This resource has been reposted with the kind permission of Bradley Kjell, and the original version can be found here (HTML or MP3). Please note that this material is under copyright and cannot be reproduced in any capacity without the explicit permission from the copyright holder.

  • 3.1.2 Importing Libraries  
  • 3.1.3 Declaring a Class  
  • 3.1.4 Compiling and Executing a Java Program  
  • 3.2 Variables, Literals, and Primitive Data Types  
  • 3.2.1 Variables vs. Literals  
    • Reading: RoseIndia.net: “Java – Variable, Constant and Literal in Java”

      Link: RoseIndia.net: “Java – Variable, Constant and Literal in Java” (HTML)

      Instructions: Please read this article.  This article explains the difference between variables and literals.

      Reading this article should take approximately 15 minutes.

      Terms of Use: Please respect the copyright and terms of use displayed on the webpage above.

    • Web Media: YouTube: Khan Academy’s “Introduction to Programs, Data Types, and Variables”

      Link: YouTube: Khan Academy’s “Introduction to Programs, Data Types, and Variables” (YouTube)

      Instructions: Please watch the lecture for an introduction to programming basic data types.  This is one of a group of Khan Lectures that are used in this course.  All of these lectures demonstrate programming concepts using Python.

      You have been introduced to Python in sub-subunit 2.1.3.2 on OO-Programming.  Python is an interpreted programming language that can be used to write procedural or object-oriented programs.  It is easy to understand and write Python programs.  One of its distinctive features is that it is dynamically typed.  This means that a declaration is not needed to declare the type of a name.  The Python interpreter determines the type of a name at execution time.  Programming languages have syntax and semantics.  Syntax is the set of grammar rules for writing statements in the language.  Semantics are the meanings attached to the statements.  For the lecture series, concentrate on the semantics or meanings.  It is not our intent to teach Python here, but to use Python to teach programming concepts.

      The value of these lectures lies primarily in the programming concepts that they demonstrate.  From sub-subunit 1.2.3, The Programming Lifecycle, you saw that programs are used to solve problems (called requirements) using a programming language.  First, one must devise a plan for solving the problem (called the design of the program).  Then, a solution must be built based on the design, using a programming language (called the implementation or program implementation)—in this lecture, Python programs.  Finally, you should test the program to check that it solves the problem (i.e. satisfies the requirements).

      In watching the lecture, focus on understanding the process of specifying the problem or requirements, the design, the program semantics, and test as well as understanding the transformation that relates these to each other.  Do not worry about the syntax of Python for now; the basics will be repeated throughout the Khan lectures.

      Watching the lecture and taking notes should take approximately 15 minutes.

      Terms of Use: Please respect the copyright and terms of use displayed on the webpage above.

  • 3.2.2 Legality of Variable Names  
    • Reading: Oracle’s The Java Tutorials: “Variables”

      Link: Oracle’s The Java Tutorials: “Variables” (HTML)

      Instructions: Please read this article.  This tutorial explains different kinds of variables in Java language.  These include instance variables, class variables, and local variables.  It also discusses the naming rules and conventions that are part of Java.

      Reading this article should take approximately 30 minutes.

      Terms of Use: Please respect the copyright and terms of use displayed on the webpage above.

  • 3.2.3 Primitive Data Types  
  • 3.2.3.1 Integers and Booleans  
  • 3.2.3.2 Chars and Strings  
    • Web Media: YouTube: Khan Academy’s “Python Lists” and “Fun with Strings”

      Link: YouTube: Khan Academy’s “Python Lists” (YouTube) and “Fun with Strings” (YouTube)

      Instructions: Please watch the two lectures.  Lists and strings are similar, in that a string can be viewed as a list of characters.  However, while similar, they are different objects with their own methods or functions used to manipulate them.  A program consists of control phrases, or statements, and data structures.  Lists and strings are two important data structures for problem solving.

      Watching these lectures and taking notes should take approximately 30 minutes.

      Terms of Use: Please respect the copyright and terms of use displayed on the webpages above.

  • 3.2.3.3 Floats, Doubles  
  • 3.3 Basic Operations in Java  
  • 3.3.1 Declaration Operators  

    Note: Pay attention to the text below the headings “Arithmetic Operators,” “Integer Operators,” and “Floating Point Operators.”

  • 3.3.2 Arithmetic Operators  

    Note: Pay attention to the text below the heading “Arithmetic Operators” to learn about various arithmetic operators in Java.

  • 3.3.3 Assignment Operators  
  • 3.3.4 Typecasting  

    Note: Pay attention to the text below the heading “Mixed Floating Point and Integer Expressions,” and read the next three slides.  Though the text in these slides do not mention it explicitly, the conversion of one type of data (integers in the example) to another type of data (floating point in the example) is automatically done by the compiler and is referred to as “type-casting” or simply “casting.”

  • 3.4 String Class  
  • Unit 4: Relational and Logical Operators in Java  

    In this unit, we will discuss relational and logical operators in Java, which provide the foundation for topics like control structures (which we will discuss further in Unit 5).  In this unit, we will start by taking a look at operator notation.  We will then discuss relational operators as they apply to both numeric operands and object operands before concluding the unit with an introduction to logical operators.  By the end of this unit, you should be able to perform comparisons and logic functions in Java and have a fundamental understanding of how they are employed.

    Unit 4 Time Advisory   show close
    Unit 4 Learning Outcomes   show close
  • 4.1 Operator Notations  
  • 4.1.1 Infix Notations  

    Note: This topic is covered by the subunit 4.1.  Please focus on the text below "Inflix Notation" on the first page.

  • 4.1.2 Postfix Notations  

    Note: This topic is covered by subunit 4.1.  Please focus on the text below "Postfix Notation" on the second page.

  • 4.1.3 Prefix Notations  

    Note: This topic is covered by subunit 4.1.  Please focus on the text below "Prefix Notation" on the first page.

  • 4.2 Relational Operators  
  • 4.2.1 Greater Than  

    Note: This topic is covered by the resource under subunit 4.2.

  • 4.2.2 Less Than  

    Note: This topic is covered by the resource under subunit 4.2.

  • 4.2.3 Equal To  

    Note: This topic is covered by the resource under subunit 4.2.

  • 4.2.4 Not Equal To  

    Note: This topic is covered by the resource under subunit 4.2.

  • 4.2.5 Greater Than or Equal To  

    Note: This topic is covered by the resource under subunit 4.2.

  • 4.2.6 Less Than or Equal To  

    Note: This topic is covered by the resource under subunit 4.2.

  • 4.3 Logical Operators  
  • 4.3.1 Uses  
  • 4.3.2 Comparing Boolean Values  

    Note: In particular, read the first five pages of this resource to understand how two Boolean expressions are compared.

  • 4.3.3 NOT, OR, AND  

    Note: Please read all the pages in this tutorial to understand the logical operators and how they are used. Please try the examples that are discussed while explaining these operators.

  • 4.3.4 Truth Tables  
  • Unit 5: Control Structures and Arrays  

    Control structures dictate what the behavior of a program will be under what circumstances.  Control structures belong to one of two families: those that test values and determine what code will be executed based on those values, and those that loop, performing identical operations multiple times.  Control structures like if-then-else and switchtell the program to behave differently based on the data that they are fed.  The while and for loops allow you to repeat a block of code as often as it is needed.  As you can see, that functionality can be very useful when designing complex programs.  This unit will introduce you to control structures and the ways in which they are used before moving on to discuss if, switch, while/do-while, and for loops.  We will also discuss some advanced topics, such as nesting and scope.  Arrays are discussed in the last subunit of this unit.  An Array is a fixed-size data structure that allows elements of same data type to be stored in it.  By the end of this unit, you should be able to draw from the information you learned in the previous unit to create a control structure, which will allow you to create more complex and useful programs.

    Unit 5 Time Advisory   show close
    Unit 5 Learning Outcomes   show close
  • 5.1 Introduction to Control Structures  
  • 5.1.1 Motivations  

    Note: Please read the first three paragraphs of the reading.  They explain how control structures can transfer the execution of a sequential code to some other part of the program based on user input or some other value.

  • 5.1.2 Types  

    Note: There are various kinds of control structures such as conditional statements, loops, and methods that control the flow of a program.  Please read the sections under headings “Conditional,” “Loops in Java,” and “Methods” to understand more about the types of conditional structures in Java.  Different type of control structures are discussed in greater detail in subunit 5.2.

  • 5.2 The ‘if’ statement  
  • 5.2.1 Uses  

    Note: As you read this tutorial, you will understand that sometimes it is important to evaluate the value of an expression and perform a task if the value comes out to be true and another task if it is false.  In particular, try the simulated program under the heading “Simulated Program” to see how a different response is presented to the user based on if a number is positive or negative.

  • 5.2.2 General ‘if-then-else’ Structure in Java  

    Note: Pay special attention to the reading under the heading “More Than One Statement per Branch” to learn how the ‘else’ statement is used when there is more than one choice.

  • 5.3 The ‘switch’ Statement  
  • 5.3.1 Uses  

    Note: As you read this tutorial, you will learn that sometimes it is better to use a ‘switch’ statement when there are multiple choices to choose from.  Under such conditions, an if/else structure can become very long and at times difficult to comprehend.  Please read the section under the heading “Many-way Branches,” and pay special attention to the syntax of the ‘switch’ statement.

  • 5.3.2 Relationship to ‘if’  

    Note: Once you have read the entire tutorial, you will understand the similarity of the logic used for the ‘if/else’ statement and ‘switch’ statement and how they can be used alternately.

  • 5.4 The ‘while’ and ‘do-while’ Loops  
  • 5.4.1 Uses  

    Note: After reading the tutorial, you will understand how a do-while loop works.  In a do-while loop, the body of the loop is executed at least one time, whereas in a while loop, the loop may never execute if the loop condition is false.  Please read the pages starting with the heading “Bottom Driven Loop” to understand the advantages of this loop.

  • 5.4.2 ‘while’ vs. ‘do-while’  

    Note: At the end of this tutorial, you will understand the difference between while and do-while loops.  They both are essentially the same except that the while loop is a pre-test loop and may never execute if the condition is false to begin with. On the other hand, the do-while loop is a post-test loop and always executes at least one time, even if the condition is false.

  • 5.5 The ‘For’ Loop  
  • 5.5.1 Uses  
  • 5.5.2 Comparison to ‘while’ and ‘do-while’  

    Note: After completing sub-subunit 5.5.1, you will have clear understanding of how a for loop is used and some of its advantages.  At this point you will be able to compare the for loop to while and do-while loops.

  • 5.6 Advanced Topics  
  • 5.6.1 Nesting Control Structures  
  • 5.6.2 Variable Scope within a Control Structure  
  • 5.7 Arrays  
  • 5.7.1 Introduction to Arrays  
  • 5.7.2 Common Array Algorithms  
    • Reading: Central Connecticut State University: Bradley Kjell’s Introduction to Computer Science Using Java: “Chapter 47: Common Array Algorithms”

      Link: Central Connecticut State University: Bradley Kjell’s Introduction to Computer Science Using Java: “Chapter 47: Common Array Algorithms” (HTML or MP3)

      Instructions: Please read this chapter.  Make sure to use the arrow keys to navigate through the webpages.  You may also click on the sound icon at the top of the page to listen to the MP3.  This chapter discusses how a for loop can used to iterate over the elements of an array.  In addition, it also discusses enhanced for loop.  The chapter demonstrates use of arrays to solve common problems such as finding sum, average, maximum, and minimum values of numbers stored in array.  Please pay attention to some of the common programing errors one can make while using arrays.

      Reading this chapter should take approximately 2 hours.

      Terms of Use: Please respect the copyright and terms of use displayed on the webpage above.

  • Unit 6: Exception Handling and Java I/O  

    In this unit, we will discuss two important programming concepts in Java: exception handling as well as input and outpout.  Exception handling mechanism allows a program to continue executing, even if an error occurs in the program, instead of terminating it abruptly. Input and output techniques allow programmers to design more complex and useful programs.  For this reason, you must fully understand how to use a programming language's built-in I/O (input/output) functionality.  In this unit, we will discuss function I/O in Java before moving on to file I/O: both writing and reading data to and from files.  Each unit will contain a discussion of the applicable Java classes, which are part of the standard programming language  FileWriter, PrintWriter, FileReader, BufferedReader, and IOException.  We will then identify the common pitfalls and design concepts that you should keep in mind as a programmer.  By the end of this unit, you will have a strong understanding of how to call functions from other functions, how to write and read from a file, and how to write a Java program that performs those functions.

    Unit 6 Time Advisory   show close
    Unit 6 Learning Outcomes   show close
  • 6.1 Method Syntax in Java  
    • Reading: MIT Open Courseware: Dr. George Kocur’s Introduction to Computing and Engineering Problem Solving: “Lecture 6: Methods, Scope”

      Link: MIT Open Courseware: Dr. George Kocur’s Introduction to Computing and Engineering Problem Solving: “Lecture 6: Methods, Scope” (PDF)

      Instructions: Please download the PDF, and review these lecture notes.  This reading will also cover the topics outlined in sub-subunits 6.1.1 – 6.1.4.

      Reading these lectures notes should take approximately 1 hour.

      Terms of Use: Please respect the copyright and terms of use displayed on the webpage above.

    • Web Media: Khan Academy’s “Defining a Factorial Function,” “Diagramming What Happens with a Function Call,” “Recursive Factorial Function,” and “Comparing Iterative and Recursive Factorial Functions”

      Link: Khan Academy’s “Defining a Factorial Function” (YouTube), “Diagramming What Happens with a Function Call” (YouTube), “Recursive Factorial Function” (YouTube), and “Comparing Iterative and Recursive Factorial Functions” (YouTube)

      Instructions: Please click on the first link above, and watch the 10-minute lecture, which implements factorial as a function.  Please note that a ‘method’ is often referred to as ‘function’ in some programming languages.  The above resource uses the term ‘function’ instead of ‘method’ as the concepts are explained using Python.

      Next, click on the second link above to watch “Diagramming What Happens with a Function Call.”  The second video (10 minutes) verifies the function design by manually diagramming what happens statement by statement and function call by function call.  This lecture also introduces variable scoping.

      Then, please click on the link to “Recursive Factorial Function.”  This third video (8 minutes) introduces recursion by implementing the factorial function using recursion.  If you are familiar with proof by induction in mathematics, you will notice its conceptual similarity with recursion.  Some verification is done by running the program for several cases.

      Finally, select the link for the “Comparing Iterative and Recursive Factorial Functions” video.  The fourth video (6 minutes) compares the loop implementation with the recursive implementation of the factorial function by stepping through them, side by side, using the same example inputs.

      Please note that though these video lectures use Python programming language to explain methods/functions, the basic idea of method and method call is the same in Java programming language.

      Watchin these lectures and taking notes should take approximately 45 minutes.

      Terms of Use: Please respect the copyright and terms of use displayed on the webpages above.

  • 6.1.1 Function Declaration  

    Note: Pages 1-2 of the reading in 6.1 explain how a method is declared in Java.

  • 6.1.2 Function Parameters  

    Note: Method parameters are explained on page 2.  Method parameters are also referred to as ‘arguments’ as written in the slides.

  • 6.1.3 Return Types  

    Note: As you read the section, you will learn that some methods do not return any value, while others return a value of certain data type.  A method that does not return a value uses the keyword ‘void’ in the method signature.

  • 6.1.4 Scope  

    Note: Read pages 4, 5, and 6 to learn about the scope of a variable.

  • 6.2 Exception Handling  
    • Reading: Central Connecticut State University: Bradley Kjell’s Introduction to Computer Science Using Java: “Chapter 80: Exceptions”

      Link: Central Connecticut State University: Bradley Kjell’s Introduction to Computer Science Using Java: “Chapter 80: Exceptions” (HTML or MP3)

      Instructions: Please read through the tutorial.  Click on the arrow keys to navigate to each webpage.  You may click on the sound icon at the top of the webpage to listen to the MP3.  Note that the resource also covers the topics outlined for sub-subunits 6.2.1 – 6.2.4.

      Reading this chapter should take approximately 2 hours and 30 minutes.

      Terms of Use: Please respect the copyright and terms of use displayed on the webpage above.

    • Web Media: YouTube: The New Boston’s “Exception Handling”

      Link: YouTube: The New Boston’s “Exception Handling” (YouTube)

      Instructions: Please watch this video as it demonstrates the use of try and catch blocks to catch exceptions in a simple Java program.  Note that this resource also covers the topic outlined in sub-subunit 6.2.3.

      Watching this video and pausing to take notes should take approximately 15 minutes.

      Terms of Use: Please respect the copyright and terms of use displayed on the webpage above.

  • 6.2.1 Exception and Errors  

    Note: Both exceptions and errors disrupt the normal execution of a program and halt the program abruptly.  Please read first three pages of the resource to understand the difference between exception and error.

  • 6.2.2 Throwable Class  

    Note: In Java, all exceptions are derived from a class called “throwable.”  Please read first three pages of the resource to understand the hierarchy of exception handling classes.

  • 6.2.3 Try and Catch Blocks  

    Note: At the very core of exception handling mechanism are the key words try and catch.  They both work together to catch problems in a program.  Read the full tutorial provided in 6.2 as well as view the video by The New Boston to understand how the try and catch blocks are used to handle problems in the code.

  • 6.2.4 Stack Trace  

    Note: Once an execution of a program stops due to a problem, JVM’s default exception handler terminates program execution and displays an error message followed by a list of method calls that lead to the exception.  This is referred to as stack trace.  Please review the resource provided under subunit 6.2 to understand stack trace and how it is printed.

  • 6.3 Input/Output in Java  
  • 6.3.1 Standard I/O  

    Note: Please read pages 1 to 4 to learn about the Standard I/O classes in Java.  You will learn about the Scanner class that is used to get input from the user.  Page 4 discusses three more I/O classes that are used to get input/ouput from the user.

  • 6.3.2 Common I/O Classes and Operations  

    Note: Please read page 5 onwards till the end to learn about various methods from the Scanner class that convert user input into appropriate data type before conducting any operation on the data.  Study and run the program called ‘Echo.java’ to understand the use of these classes and the program’s methods.

  • 6.3.3 String Formation  
  • 6.4 Writing Data to a File  
  • 6.4.1 The FileWriter Class in Java  
  • 6.4.2 The PrintWriter Class in Java  
  • 6.5 Reading Data from a File  
  • 6.5.1 The FileReader Class in Java  

    Note: This tutorial explains the Java I/O API and discusses Reader classes in detail.  The second page shows Reader Stream class hierarchy.  FileReader and BufferedReader classes are used together when reading data from an external file.  Please study the example on page 4 to see how these classes are used.  Also, copy and paste the code on page 4 in a newNetBeans file, and run the program on your machine.

  • 6.5.2 The BufferedReader Class in Java  

    Note: Please read page 4 to learn about BufferedReader class.  The use of this class allows data to be buffered as it is read from the file before manipulating it.

  • Final Exam  

« Previous Unit Next Unit » Back to Top