Computer Programming I: An Introduction To Computers and Java
Computer Programming I: An Introduction To Computers and Java
Chapter 1
An Introduction to Computers and
Java
1
What is a computer?
2
What is a Computer?
A computer is a machine that performs
computations, logical operations, or more
generally, data manipulation according to some
prescribed sequence of instructions called a
computer program.
3
The Hardware
The major hardware components:
4
Computer Companonts
5
The Central Processing Unit
The CPU does:
the computing
the processing
the bulk of the work
6
The Central Processing Unit
The ALU performs calculations, billions per
second
The CU controls or coordinates which calculations
the ALU performs
The CPU clock determines how frequently the
computer hardware executes instructions.
A system’s hardware components are synchronized
with the clock. Every time the clock ticks, another
hardware action occurs.
7
Primary or Random Access Memory
How Data is Stored
binary format
a sequence of 0’s and 1's called bits.
ASCII encoding:
‘a’ is represented by 01100001
‘b’ is encoded as 01100010
9
Where Data Is Stored
You can conceptualize
RAM as a collection of
storage cells or boxes,
each capable of
holding just a single
byte of information.
A unique number, or
memory address,
identifies each such
storage cell.
10
Secondary Memory
Long term
Permanent storage
12
Input/Output Devices
Standard input devices: Output devices:
keyboards monitors
mouses printers
joysticks speakers
stylus pens
cameras
microphones
13
The Software
The programs that run on a computer are collectively
known as software. Word processors, internet
browsers, editors, database management systems,
computer games, and spreadsheets are all part of
your computer's software library.
14
Computer Software
Application Software
Refers to programs that are developed to solve some
specific problems.
There are two types of application software:
application program to solve special classes of problems
Application programs that you can write to solve your
own problems.
Examples of application software:
word processing
database programs
spreadsheets
graphic programs
15
Computer Software
System Software
Refers to programs that make the computer usable
and accessible to the developers and programmers of
applications software.
Examples of system software:
Operating systems
Language translator
Linker
Loader
Preprocessors
16
Programming Languages
Programming Language is an agreed upon
format of symbols that allow a programmer to
instruct a computer to perform certain
predefined tasks.
Provide features to support the data processing
activities, which include declaring variables,
evaluating numeric expressions, assigning
values to variables, reading and writing data to
devices, looping and making decisions.
17
Programming Languages
a. Machine Languages
Is the natural language of a computer.
Does not need to translate and is ready for immediate
execution.
Machine language instruction is a binary string of 0s and
1s.
010 1 1000 0001 0000 1100 0000 0001 0000
18
Programming Languages
Machine Language
19
Programming Languages
Assembly Languages
21
Programming Languages
For example:
COBOL – developed in the 1960s for business
transactions.
FORTRAN – developed for mathematic calculations.
Pascal - is a structured high-level language.
C – is designed to support only procedure-oriented
programming. Popular language for developing system
applications such as operating system and compilers.
Java – is an object-oriented language.
C++ - is extension of C programming language that
support object oriented programming and procedure-
oriented approach.
22
Programming Languages
In the 1960s, the first high-level language,
FORTRAN, was invented and no longer were
programmers forced to devise programs with binary
instructions. FORTRAN instructions use an
English-like syntax.
23
Programming Languages
A typical instruction coded in a high-level
language:
24
The Compiler
The program must be translated into the machine
language of that computer.
010010010110010110
101100010110010111
010110101101010010
Java
General-purpose language developed by Sun
Microsystems in the early 1990s. Three main goals
for their new language:
28
The Java Virtual Machine
The Java interpreter, which is part of the JVM,
executes each bytecode instruction, one by one.
hello
hello
30
Programming and Algorithms
An algorithm is a finite, step-by-step procedure for
accomplishing some task or solving a problem.
31