CSC Course – 2/4/17

Professor: Ayman Zeidan


Chapters 1-6

Exam 1: covers chapters 1-2

Exam 2: covers chapters 3-4

Final: covers chapters 1-6


Java History

-1991, Green Team started by Sun Microsystems

-*7 handheld controller for multiple entertainment systems.

-There was a need for a programming language that would run on various devices.

-Java (first named Oak) was developed for this purpose.


-Java enabled web browser (HotJava) Demonstrated at 1995 Sun World Conference.

-Java incorporated into Netscape shortly after.

-Java is “cross-platform”, meaning that it can run on multiple systems.

Java applications and applets

-Java programs can be of two types:

-Applications: Stand-alone programs that run without the aid of a web browser. Had a relaxed security model since the user runs the program locally.

-Applets: Small applications that require the use of a Java enabled web browser to run. Had a enhanced security model since the user merely goes to a web page and the applet runs itself.

Why program?

-Computers are tools that can be programmed to perform many features such as:

  • Spreadsheets
  • Databases
  • Word processing
  • Games
  • Etc.

-Computers are versatile because they can be programmed.

-Computer programmers implement programs that perform these functions.

-Aspects of a computer program that must be designed:

  • The logical flow of the instructions.
  • Programs must be analytically correct as well.
  • Programs rarely work the first time they are programmed.
  • Programmers must perform the following on a continual basis:
    • Analyze
    • Experiment
    • Correct and Redesign
  • Programming languages have strict rules, known as syntax, that must be carefully followed.

Computer Systems:Hardware

-Computer hardware components are the physical pieces of the computer.

-The major hardware components of a computer are:

  • The central processing unit (CPU)
  • Main memory
  • Secondary storage device
  • Input and output devices

Central processing unit

-Arithmetic logic unit

-Control unit

-The CPU performs the fetch, decode, execute cycle in order to process program information.

-The CPU’s control unit fetches from the main memory, the next instruction in the sequence of program instruction.

-The instruction is encoded in the form of a number. The control unit decodes the instructions and generates an electrical signal.

-The signal is routed to the appropriate component of the computer. The signal causes the component to perform an operation.

Computer systems:Hardware:Main memory

-Commonly known as random-access memory (RAM).

-RAM contains:

  • Currently running programs
  • Data used by those programs.

-RAM is divided into unites called bytes.

-A byte consists of eight bits that may be either on or off.

1 bit = 0 or 1

1 byte = 8 bits

1 KB = 1000 bytes = 8000 bits

1 MB = 1,000,000 bytes

1 GB = 1,000,000,000 bytes

1 TB = 1,000,000,000,000 bytes

and so on

-A bit is either on or off.

  • 1 = on
  • 0 = off

-The bits form a patter that represents a character or a number.

-Each byte in memory is assigned a unique number known as an address.

-RAM is volatile, which means that when the computer is turned off, the contents of the RAM is erased.

-Main memory can be visualized as a row or column of cells.

  • A section of memory is called a byte.
  • A byte is made of 8 bits.
  • A section of two or four bytes is often called a word.

Computer systems:Hardware:Secondary storage

-Secondary storage devices are capable of storing information for longer periods of time (non-volatile).

-Common secondary storage devices:

  • Disk drive
  • External drive
  • CD Drive
  • Solid-State Drive
  • USB Drive
  • DVD Drive

Computer systems:Hardware:Input devices

-Input is any data the computer collects from the outside world.

-That data comes from devices known as input devices.

-Common input devices:

  • Keyboard
  • Mice
  • Scanners
  • Digital Camera

Computer systems:Hardware:Output devices

-Output is any data the computer sends to the outside world.

-That data is displaced on devices known as output devices.

-Common output devices:

  • Monitors
  • Printers

-Some devices such as disk drives perform input and output functions are called I/O devices.

Computer systems:Software

-Software refers to the programs that run on a computer.

-There are two classifications of software:

  • Operating system
  • Application software

Computer systems:Software:Operating systems

-An operating system is a set of programs that manages the computer’s hardware devices and controls their processes.

-Most all modern operating systems are multitasking.

-A multitasking operating system is capable of running multiple programs at once.

  • Unix
  • Linux
  • Mac OS
  • Windows

-The technique is called time sharing.

-A multitasking system divides the allocation of hardware resources and the attention of the CPU among all the executing programs.

Computer systems:Software:Application software

-Application software refers to programs that make the computer useful to the user.

-Application software provides a more specialized type of environment for the user to work in.

Programming Languages

-A program is a set of instructions a computer follows in order to perform a task.

-A programming language is a special language used to write computer programs.

-A computer program is a set of instructions that enables the computer to solve a problem or perform a task.

-Collectively, these instructions form a algorithm.

-An algorithm is a set of well defined steps to completing a task.

-The steps in a algorithm are performed sequentially.

-A computer needs the algorithm to be written in machine language.

-Machine language is written using binary numbers.

-The binary numbering system (base 2) only has two digits (0 and 1).

-The binary numbers are encoded as a machine language.

-Each CPU has its own machine language.

  • Motorola 6800 series processors
  • Intel x86 series processors
  • ARM processors
  • Etc.

-Example of a machine language instruction: 1011010000000101.

-In the distinct past, programmers wrote programs in machine language.

-Programmers developed higher level programming languages to make things easier.

-The first of these was assembler.

-Assembler made things easier but was also processor dependent.

-High level programming languages followed that were not processor dependent.

-Some common programming languages:

  • Java
  • Pascal
  • C
  • C++
  • C#
  • PHP
  • Visual Balance
  • Python
  • Ruby
  • JavaScript

Programming languages:Common language elements

-There are some concepts that are common to virtually all programming languages.

Programming languages:Sample program

public class Hello World


public static void main (string [] args)


String message = “Hello World”;

system.out.println (message);



-Keywords in the sample program are:

  • public
  • class
  • static
  • void

-Keywords are lowercase (Java is a case sensitive language).

-Keywords cannot be used as a programmer defined identifier.

-A semi-colon are used to end Java statements; however, not all lines of a Java program end a statement.

-Part of learning Java is to learn where to properly use the punctuation.

Programming languages:Lines V.S. statements

-There are differences between  lines and statements when discussing source code.

system.out.println (


-This is one Java statement written using two lines. Do you see the difference?

-A statement is a complete Java instruction that causes the computer to do something.

Programming languages:Variables

-Data in a Java program is stored in memory.

-Variable names represent a location in memory.

-Variables in Java are sometimes called fields.

-Variables are created by the programmer who assigns it a programmer-defined identifier.

Example: int hours = 40;

-In this example, the variable, hours, is created as an integer (more on this later) and assigned the value of 40.

-Variables are simply a name given to represent a place in memory.

-Assume that this variable declaration has been made.

int length = 72;

-The variable, length, is a symbolic name given for the memory location.

-The Java Virtual Machine (JVM) actually decides where the variable is located in memory.

The Compiler and The Java Virtual Machine

-A programmer writes Java programming statements for a program.

-These statements are known as a source code.

-A text editor is used to edit and save a Java source code file.

-Source code files have a .Java file extension.

-A compiler is a program that translates source code into a executable form.

-A compiler is run using source code file as a input.

-Syntax errors that may be in the program will be discovered during the compilation.

-Syntax errors are mistakes that the programmer has made that violate the rules of the programming language.

-The compiler creates another file that holds the translated instructions.

-Most compilers translate source code into executable files containing machine code.

-The Java compiler translate a Java source file into a file that contains byte code instructions.

-Byte code instructions are the machine language of the Java Virtual Machine (JVM) and cannot be directly executed directly by the CPU.

-Byte code files end with the .class file extension.

-The JVM is a program the emulates a micro-processor.

-The JVM executes instructions as they are reading.

-The JVM is often called an interpreter.

-Java is often referred to as an interpreted language.

Program Development Process

-Text Editor saves Java statements and results in a source code ending with  a .Java file extension.

-The source code is then read by the Java compiler.

-The Java compiler compiles it to Byte code which ends with a .class file extension.

-The byte code is then translated by the JVM.

-The JVM translated code results in a program execution.


-Portable means that a program may be written on one type of computer and then run on a wide variety of computers, with little or no modifications.

-Java byte code runs on the JVM and not on any particular CPU; therefore, compiled Java programs are highly portable.

Compiling a Java Program

-The Java compiler is a command line utility.

-The command to compile a program is: javac

-javac is the Java compiler.

-If there are no syntax errors, the compiler will translate it to byte code.

The Programming Process

  • Clearly define what the program is to do.
  • Visualize the program running on the computer
  • Use design tools to create a model of the program.
  • Check the model for logical errors.
  • Enter the code and compile it.
  • Correct any errors found during the compilation.
  • Run the program with test data for input.
  • Correct any run-time errors.
  • Validate the results of the program.

Software Engineering

-Encompasses the whole process of crafting computer software.

-Software engineers perform several tasks in the development of complex software projects.

-Software engineers develop:

  • Program specifications
  • Diagrams of screen outputs
  • Diagrams representing the programming components
  • Pseudcode
  • Examples of expected input and desired amounts
  • special software designed for testing programs

-Software engineers also use special software designed for testing programs.

-Most commercial software applications are large and complex.

-Usually a team of programmers, not a single individual develops them.

-Program requirements are thoroughly analyzed and divided into subtasks that are handled by:

  • Individual teams
  • Individuals within a team

Procedural Programming

-Older programming languages was procedural.

-A procedure is a set of programming language statements that, together, perform a specific task.

-Procedures typically operate on data items that are separate from the procedures.

-In a procedural program, the data items are commonly passed from one procedure to another.

-In procedural programming, procedures are developed to operate on the programs data.

-Data in the program tends to be global to the entire program.

-Data formats might change and thus, the procedures that operate on that data must change.

Object Oriented Programming

-Object oriented programming is centered on creating objects rather than procedures.

-Objects are a melding of data and procedures that manipulate that data.

-Data in an object are known as attributes.

-Procedures in an object are known as methods.

-Objected oriented programming combines data and behavior via encapsulation.

-Data hiding is the ability of an object to hide data from other objects in the program.

-Only an object method should be able to directly manipulate these attributes.