Harnessing Technology to make education free

Blog / ePortfolio / Forums / 289 courses / FAQ / digedcon

Introduction to Computer Science I

Purpose of Course  showclose

This course will introduce you to the field of computer science and the fundamentals of computer programming.  This course has been specifically designed for students with no prior programming experience, and taking this course 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 (now Oracle), 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.  This course will cover basic object-oriented programming terminology and concepts such as objects, classes, inheritance, and polymorphism in addition to discussing fundamentals of Java, its primitive data types, relational operators, control statements, exception handling, and Java I/O.  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 Information  showclose

Welcome to CS101.  Below, please find some general information on the course and its requirements.
 
Primary Resources: This course is comprised of a range of different free online materials.  However, the course makes primary use of the following materials:
Requirements for Completion: In order to complete this course, you will need to work through each unit and all of its assigned materials.  Pay special attention to Unit 1, as this introduction lays the groundwork for understanding the more advanced, exploratory material presented in latter units.  You will also need to complete the Final Exam.
 
Note that you will only receive an official grade on your Final Exam.  However, in order to adequately prepare for this exam, you will need to work through all of the resources in each unit.
 
In order to “pass” this course, you will need to earn a 70% or higher on the Final Exam.  Your score on the exam will be tabulated as soon as you complete it.  If you do not pass the exam, you may take it again.
 
Time Commitment: Completing this course should take you a total of 89.75 hours.  Each unit includes a “time advisory” that lists the amount of time you are expected to spend on each subunit.  These should help you plan your time accordingly.  It may be useful to take a look at these time advisories and to determine how much time you have over the next few weeks to complete each unit, and then to set goals for yourself.  For example, Unit 1 should take you 16.5 hours.  Perhaps you can sit down with your calendar and decide to complete subunit 1.1 (a total of 3 hours) on Monday; sub-subunit 1.2.1 (a total of 2.5 hours) on Tuesday; sub-subunits 1.2.2 and 1.2.3 (a total of 4.25 hours) on Wednesday; etc.
 
Tips/Suggestions: As you read or view resources, take careful notes on a separate sheet of paper.  These notes will be useful to use as a study guide when you prepare for the Final Exam. 

Learning Outcomes  showclose

Upon successful completion of this course, you will be able to:
  • discuss the history of computing as well as fundamental hardware and software concepts;
  • explain the programming life cycle;
  • explain how the JVM translates Java code into executable code;
  • explain Object-Oriented Programming concepts such as objects, classes, inheritance and polymorphism;
  • write simple programs using basic Java concepts;
  • discuss and use primitive data types in Java;
  • discuss and use logical and relational operators and compare Boolean expressions;
  • explain and use various control structures such as methods, decision statements, and loops;
  • use exception handling mechanism; and
  • use Java input/output class hierarchy to read and write data to and from external files. 

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.);

√    have competency in the English language; and

√    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  
  • 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.

  • 1.2.3 The Programming Lifecycle  
  • 1.2.3.1 Concept  
  • 1.2.3.2 Design  

    Note: Once you have listened the tutorial on the introduction to the waterfall model, please click ‘continue’ to hear the tutorial on the requirements and the design process.  Please take notes as you listen to this audio tutorial.

  • 1.2.3.3 Development/Implementation  

    Note: Continue listening to the audio tutorial to learn about software development and implementation process.

  • 1.2.3.4 Testing  

    Note: After listening to the section on development/implementation process, listen to the section on testing by clicking the ‘continue’ button.

  • 1.2.3.5 Deployment  

    Note: Once the software is tested, the next step is to deploy it. Please continue listening to the tutorial for the section on deployment by clicking the ‘continue’ button.

  • 1.2.3.6 Support  

    Note: Once the software is deployed, the customers need to be supported. After listening to the section on deployment, click on the ‘continue’ button to listen to information about support.

  • 1.2.3.7 Maintenance  

    Note: The deployed software needs to be maintained and upgraded as needed. Please click on the ‘continue’ button to listen to the section on maintenance.

  • 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)  
  • 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  
  • 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  
  • 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