Tuesday June 6, 2000
Quiz 1
1. What are the three types of errors that can occur in programming?
2. What is the program javac called?
3. What does it produce?
4. What does JDK stand for?
Let us consider some basic terms related to computers.
- CPU - the Central Processing Unit. The CPU fetches instructions from
main memory and executes them.
- Main Memory - the portion of memory used to hold program as they are
being executed. Main memory is directly accessed by the CPU. Often main
memory is a combination of RAM and ROM.
- ROM - Read Only Memory.
- RAM - Random Access Memory.
- Kilobyte - 1,024 (210) bytes.
- Megabyte - 1,048,576 (220) bytes.
- Megahertz - a unit of measurement for how fast a system clock is
ticking. 1 megahertz is 1 million cycles per second. Some systems are
rated as much as 1000 megahertz or 1 gigahertz. The original IBM PC was
4.7 MHz.
- microprocessor - when a CPU is manufactured on a single chip, it is
referred to as a microprocessor.
- microcomputer - a computer based on a microprocessor.
- cache memory - extra fast memory that can sit between the processing
unit and main memory. Instructions can be fetched faster from cache than
from main memory.
Before we begin to look at specifics of the Java programming language, we
need to step back for a minute and examine the basics of the binary number
system. Recall that the CPU can only understand instructions that are sets
of 0's and 1's. The reasons behind this go back to the design of
computers. Electrical voltage can be used to encode data. Different
voltages can be used to mean different things. It was found that the
simplest way to use electrical voltage was to use a high and low voltage.
That is, when a high electrical voltage (e.g. 5 V) is detected, the CPU
can interpret that as a 1. When a low electrical voltage is detected, the
CPU can interpret that as a 0.
The system of numbers that consists only of 0's and 1's is called the
binary number system. We can constrast this to the ordinary decimal
system, which has ten digits, 0-9. Two other important number systems are
the octal number system, and the hexadecimal number system. Let us look at
the particulars of these number systems.
The Binary System or base 2. Consists only of the digits 0 and
1. The two
units are usually referred to as bits. Bits are the smallest unit that a
computer can understand. Instructions at the machine level consist of
sequences of 0's and 1's.
The Octal System or base 8. Consists of the digits 0-7.
The Decimal System or base 10. Consists of the digits 0-9.
The Hexadecimal System or base 16. This is a system of numbers
with 16
digits. The ordinary digits 0-9 are used and the letters A,B,C,D,E, and F
are also used. Their decimal equivalents are, respectively,
10,11,12,13,14, and 15.
Notice that there is a special connection between three of these systems.
Conversions between number systems.
Consider the number 455 in base 10. The value of this number is given by
4x102 + 5x101 + 5x100.
In base two the number 11 has the value
1x21 + 1x20 = 3
in base 10.
What we would like to consider now is how we go about converting numbers
from base 2 into base 10, and vice versa.