Professional Documents
Culture Documents
The word computer refers to a system composed of many components. A computer system has both hardware and software components. This chapter discusses these components. Chapter Topics:
Computer Systems. Hardware and Software. Hardware components of a computer system. Software components of a computer system. Networks. World-Wide Web.
QUESTION 1:
combine tangible components called hardware and conceptual components called software.
QUESTION 2:
Imagine that you have a copy of Mark Twain's "Tom Sawyer". You tear it to pieces and push the shreds through your garbage disposal. Have you destroyed "Tom Sawyer"?
You probably have a computer in front of you. The processor, main memory, and secondary memory devices are inside the systems unit. This is the metal box that is sometimes called "the computer." The monitor (the TV-like screen) is an output device.
QUESTION 3:
Hardware Components
The terms "input" and "output" say if data flow into or out of the systems unit. The picture shows the major hardware components of a computer system. The arrows show the direction of data flow.
The bus is a group of wires on the main circuit board of the computer. It is a pathway for data flowing between components. Most devices are connected to the bus through a controller which coordinates the activities of the device and the bus. The processor is an electronic device about a one inch square, covered in plastic. Inside the square is an even smaller square of silicon containing millions of tiny electrical parts. A processor may contain 100 million transistors. The processor is the "brain" of the computer system. It does the fundamental computing within the system, and directly or indirectly controls all the other components. The processor is sometimes called the Central Processing Unit or CPU. A particular computer will have a particular type of processor, such as a Pentium or a SPARC chip. (processors are often called "chips.") Click Here to see the computer system these notes were prepared on. (It probably looks much like what you are yourself using.) You might notice that it is 5 years old. It works fine for running Java programs.
QUESTION 4:
Say that a computer has just added 13 to 27. Where did this activity take place?
Memory
The processor is the brain of the computer. All fundamental computing takes place in the processor. Other components contribute to the computation (by doing such things as moving data in and out of the processor), but the processor is where the fundamental action takes place.
Unlike a human brain, which combines memory with processing power, a computer processor has very little memory. It must rely on other components to hold data and programs and to save results. The memory in a computer system is of two fundamental types:
Main memory: o very closely connected to the processor. o the contents are quickly and easily changed. o holds the programs and data that the processor is actively working with. o interacts with the processor millions of times per second. Secondary memory: o connected to main memory through the bus and a controller. o the contents are easily changed, but this is very slow compared to main memory. o used for long-term storage of programs and data. o The processor only occasionally interacts with secondary memory.
Main memory is where programs and data are kept when the processor is actively using them. When programs and data become active, they are copied from secondary memory into main memory where the processor can interact with them. A copy remains in secondary memory. Main memory is intimately connected to the processor, so moving instructions from the program and data into and out of the processor is very fast. Main memory is sometimes called RAM. RAM stands for Random Access Memory. "Random" means that the memory cells can be accessed in any order. When people say that a computer has "128 megabytes of RAM" they are talking about how big its main memory is. One megabyte of memory is enough to hold approximately one million characters of a word processing document. (There will be more about bytes and megabytes later on in these notes.) Nothing permanent is kept in main memory. Sometimes data are placed in main memory for just a few seconds; only as long as they are needed.
QUESTION 5:
Imagine that you are using a word processor program to write a letter.
Where (in the computer system) is the program you are running? Where are the characters you have typed?
Where (in the computer system) is the program you are running? o In main memory. (A permanent copy will also be in secondary memory--the hard disk).
Where are the characters you have typed? o In main memory. (When you "save" your document, they will be copied to a file on the hard disk.)
Secondary Memory
Secondary memory is where programs and data are kept on a long-term basis. Common secondary storage devices are the hard disk and floppy disks. The hard disk has enormous storage capacity compared to main memory. The hard disk is usually contained in the systems unit of a computer. The hard disk is used for long-term storage of programs and data. Data and programs on the hard disk are organized into files--named sections of the disk.
A hard disk might have a storage capacity of 40 gigabytes. This is about 300 times the amount of storage in main memory (assuming 128 megabytes of main memory.) However, a hard disk is very slow compared to main memory. The reason for having two types of storage is this contrast:
Primary memory 1. Fast 2. Expensive 3. Low capacity 4. Connects directly to the processor Secondary memory 1. Slow 2. Cheap 3. Large capacity 4. Not connected directly to the processor
Floppy disks are mostly used for transferring software between computer systems and for casual backup of software. They have low capacity, and are very, very slow compared to other storage devices.
QUESTION 6:
You have just purchased a copy of the computer game Tomb Raider (you were waiting for the price to fall below $20). You follow the directions on the package and install the game on your computer. Tomb Raider consists of
A program (that controls the action of the game.) Data (the images and other information.)
After you have installed the game, where does each of these things exist in the computer system? After you have installed the game, where do its parts exist?
A program (that controls the action of the game.) o On the hard disk Data (the images and other information.) o On the hard disk
(When you play the game, its various parts are copied into and out of main memory.)
An output device is used to send data out of the system. Some output devices are:
Input/output devices are usually called I/O devices. They are directly connected to an electronic module inside the systems unit called a device controller. For example, the speakers of a multimedia computer system are directly connected to a device controller called an audio card (such as a Soundblaster), which in turn is connected to the rest of the system. Sometimes secondary memory devices like the hard disk are called I/O devices (because they move data in and out of main memory.) What counts as an I/O device depends on context. To a user, an I/O device is something outside of the system box. To a programmer, everything outside of the processor and main memory looks like an I/O devices. To an engineer working on the design of a processor, everything outside of the processor is an I/O device.
QUESTION 7:
Most modern automobiles are controlled by a computer. Do you think that the computer in your car has:
Input devices?
Software
A computer that is dedicated to running a program that controls another device is an embedded system. An embedded system is usually embedded inside the device it controls. Usually they run just one program that is permanently kept in a special kind of main memory called ROM (for Read Only Memory). More processor chips are sold per year for embedded systems than for all other purposes. Software is the programs and data that a computer uses. Software is kept on some hardware device such as a hard disk or floppy disk, but it itself is intangible. Say that you have a floppy disk with a program saved on it. Now say that you erase the program from the disk. The atoms and molecules of the disk are the same ones as before, but now the program is "gone." The intangible software has been removed without removing anything tangible. Software consists of both programs and data. Programs are lists of instructions for the processor. Data can be any information that a program needs: character data, numerical data, image data, audio data, and countless other types. The distinction between programs and data is not as clear-cut as you might think, however. Fundamental Idea: Both programs and data are saved in computer memory in the same way. The electronics of computer memory (both main memory and secondary memory) make no distinction between programs and data. The insight that both programs and data can be saved using the same electronic methods is one of the most important ideas in computer science. Computer systems can use their memory for whatever needs arise.
QUESTION 8:
A game program. Accounting data (numbers.) Audio data. Graphics data. Digital photographs. Video data.
Types of Programs
There are two categories of programs. Application programs (usually called just "applications") are programs that people use to get their work done. Computers exist because people want to run these programs. Systems programs keep all the hardware and software running together smoothly. The difference between "application program" and "system program" is fuzzy. Often it is more a matter of marketing than of logic.
Application Programs
Systems Programs
Word processors Game programs Spreadshee ts Data base systems Graphics programs
Operating system. Networking system. Database system. Programming language software. Web site server.
Data backup.
Web browsers
The most important systems program is the operating system. The operating system is always present when the computer is running. It coordinates the operation of all the hardware and software components of the computer system. The operating system is responsible for starting application programs running and finding the resources that they need. When an application program is running, the operating system manages the details of the hardware for it. For example, when you type characters on the keyboard, the operating system determines which application program they are intended for and does the work of getting them there. Modern operating systems usually come with a user interface that enables users to easily interact with application programs (and with the operating system itself) by using windows, buttons, menus, icons, the mouse, and the keyboard. Examples of
operating systems are Unix, Windows 98, Windows NT, Linux, Solaris, and System 7.
QUESTION 9:
(Thought question:) Imagine that you have just turned on your computer and have not yet started any application. Are any programs running?
Operating Systems
The operating system is a complex collection of many programs concerned with keeping the hardware and software components of a computer system coordinated and functioning. It is like a shop keeper who keeps a shop in order by attending to customers, handling supplier deliveries, stocking the shelves, doing the bookkeeping, and so on. The operating system is software; the same hardware can be used with many different operating systems (although only one at a time.) Sometimes the operating system on a computer becomes corrupted (perhaps because of a computer virus) and must be tediously re-installed. Until it is up and running again, other programs will not be available.
QUESTION 10:
What component of a computer system holds the operating system when the computer is not running?
Starting a Program
When a computer is started up, the hardware will automatically load the operating system and start it running. This process is called booting. The reason for this odd term is that the operating system is itself involved in getting itself running---a process that is like someone "pulling themselves up by their bootstraps." Once the operating system is running, it is used to start up any other program.
Here is a (simplified) list of what happens when the user (you) starts up an application. Assume that the operating system (OS) is already running. 1. The user asks to run an application. o This could be done by clicking on an icon, making a menu choice, or other means. 2. The OS determines the name of the application. 3. The OS finds the section of the hard disk where the application program and its data are stored. 4. The OS finds an unused section of main memory that is large enough for the application. 5. The OS makes a copy of the application and its data in that section of main memory. o The software on the hard disk is unchanged; a copy of it has been made in main memory 6. The OS sets up resources for the application. 7. Finally, the OS starts the application running. As the application runs, the OS is there in the background managing resources, doing input and output for the application, and keeping everything else running.
QUESTION 11:
When an application is closed (stops running), do you think that it is copied from main memory back to the hard disk?
Networks
A computer network consists of two or more computers connected so that they can exchange data and programs. When a computer is a member of a network, the programs it runs and the data it uses can be on the hard disk of some other computer on the network. In business and industrial settings, most computers are on a network. The operating system that runs on a networked computer must manage its share of the network (along with managing all its other responsibilities.) The operating system is able to find programs and data that are stored on other network computers, and copy them into its own main memory. In a local-area network only a few dozen computers are connected together, usually all located within the same building. Each computer has a network address that the other computers use to access it. Usually the computers share a printer. There may be an especially powerful computer called a server whose hard
disk holds all the application programs and data that the other computers are expected to need. Each computer in a network has a network interface card in its systems unit. This is an input/output device that sends and receives data over cables. The network interface cards of computers on a network are connected together with cables.
QUESTION 12:
(Thought question:) Say that the server computer of a local area network has the only copy of WordPerfect (a word processor application.) Now ten users of other computers on the network each ask to run WordPerfect. Can this be done?
Wide-Area Networks
Large organizations need to connect many more computers than can be handled with a local area network. A wide-area network can connect thousands of computers together over great distances. The long distance connections are made by using fiber optic lines, telephone lines, microwave communications, and satellite communications. Each computer in the network has a network address (as with local-area networks) to uniquely identify it. Wide-area networks use a variety of special hardware to manage the flow of data. When two computers share data, this hardware makes it appear that the two computers are connected together directly. In reality, there may be dozens of network devices between the two computers. All these devices use the same method for dealing with data. Without a common method of dealing with data, a large network would become a hopeless muddle. An agreement about how to represent and transmit data over a network is called a protocol. Usually large networks use a protocol called TCP/IP (for transmission control protocol/internet protocol.) The Internet consists of many wide-area networks that have been connected together to form one huge worldwide network. Even on this huge network, each computer must have a unique network address, much like each telephone in the world has a unique telephone number (if you include the country code and area code.)
QUESTION 13:
QUESTION 14:
Would the World-Wide Web and the Internet have been possible without the United States' space program of the 1960s?
Hyperlinks
One Web page is connected to another with a hyperlink. If you have been reading these notes over the Web, you have been linking between Web pages by using hyperlinks. A web browser (such as Netscape Navigator) usually displays a hyperlink in a distinguishing color (usually blue.) When you click on it, the browser asks the operating system of the computer to get a particular Web page from another computer connected to the Internet. The Web page to get is specified with a uniform resource locator URL. A URL specifies both the computer (among all the Internet computers in the world) and the exact Web page on that computer. To see some examples of URLs, keep watching the box in your browser labeled "Location:"
QUESTION 15:
When you click on the following hyperlink, will the URL in the "Location:" box change?
Hardware and software. Major hardware components of a computer system Types of memory Characteristics of a hard disk. I/O devices Two categories of programs The operating system. How programs start running. Computer networks
The next chapter will discuss analog and binary signals and why binary signals are important in computer systems.
Study these topics carefully if you want to know what is really going on with computers.
QUESTION 1:
Binary
Binary means "two states." The two states are sometimes called "1" and "0", or called "true" and "false", or called "on" and "off", (or other names.) The essential characteristic is that a single binary device can be in just one of two possible states. A bit is a single "on/off" value. A good example is a toggle switch, such as a light switch. You can turn it "on" or "off" but not (in normal operation) anything else. A light switch holds one bit of information. A light dimmer is not a binary device: it has many positions between "off" and "fully on". If you want a light dimmer in to be set to 25%, you must carefully adjust it.
QUESTION 2:
The ignition switch of an automobile. The hour hand of a clock. A button on a hand calculator. The volume control on a stereo.
The ignition switch of an automobile. No The hour hand of a clock. No A button on a hand calculator. Yes The volume control on a stereo. No
The ignition switch of an automobile is discreteit has definite statesbut there are usually more than two states (off, running, start, acc...) A button on a hand calculator is a binary device. It is either on or off. Ordinarily it is "off." When you push it, it is "on." It springs back to "off" when you release it, which is different from a toggle switch, but it still is a binary device. There are many advantages to binary. Here are four (somewhat overlapping) important reasons for using binary: 1. Simple; easy to build. 2. Unambiguous signals (hence noise immunity). 3. Flawless copies can be made. 4. Anything that can be represented with some sort of pattern can be represented with patterns of bits. These characteristics of binary were realized by Claude Shannon, a mathematician at Bell Telephone Laboratories. His 1948 paper A Mathematical Theory of Communication is the foundation of information theory and much of computer science.
QUESTION 3:
An on/off switch.
The same is true for the tiny devices inside of a silicon chip. On/off switches are relatively easy to fabricate. Easy to build means that the devices are cheap, small, and reliable, and millions of them can be put in a small area.
QUESTION 4:
Which of the following methods for producing books is simple and easy?
clay. Each book is individually made by copying the characters onto paper with pen and ink. Many copies of the book are made by carving flat wooden blocks with the text then printing the text on paper. Many copies of the book are made by setting movable type and printing the text on paper.
Setting type.
QUESTION 5:
Which is easier to do: (a) determine exactly how bright a light is, or (b) decide if it is on or off?
QUESTION 6:
An Analog Signal
An analog signal may continuously change in value. Its values can be anything within a range of values, and its exact value at any time is important. The graph
below represents an audio signal. The exact value at each time is part of the information it contains. For example, the value at time "T2" must be measured exactly.
Now say that you are observing the voltage of a wire. It has been agreed that any voltage below a threshold will be counted as an "off" signal, and that any value above the threshold will be counted as an "on" signal.
QUESTION 7:
Binary Signal
Analog signals continuously change in value. By using a threshold, analog signals can represent binary data ("on/off" data). It is easy and fast (for electronics, as well as for humans) to determine if a voltage is above or below a threshold. The figure shows a signal that transmits "off" then "on". (The signal is examined at times T1 and T2.)
QUESTION 8:
Is is clear that the signal is "off" at time T1 and "on" at time T2?
Imperfect Transmission
The "ons" and "offs" of previous signal are clear. But what if the signal is sent down a long wire and someone nearby turns on a vacuum cleaner? The graph shows the signal at the other end of the wire. Even though the signal is noisy (at the analog level), the binary values are transmitted perfectly. You (and the electronics) can still tell that at time T1 the signal represents "off" and that at time T2 the signal represents "on" The receiving end just needs to get the binary values.
Since only the "on" "off" information matters, the analog noise is irrelevant, and the original signal is received perfectly (so far as the binary information goes.)
QUESTION 9:
If the signal were regarded as an analog signal, and exact values were important, would some information present in the first signal (before the noise) have been lost?
Flawless copies can be made: The receiving end of the signal is only interested in the binary values. All it has to do it check if the signal is above or below the threshold. This can be done perfectly (as long as the noise is not too great.) For example, here is the noisy signal with the "on"/"off" values recovered from it:
The original signal has been recovered flawlessly. This process can occur as many times as needed with a perfect copy made each time. This is essential in a computer system, where bit patterns (patterns of one and zero, or on and off) are copied back and forth between the processor and memory millions of times a second. The copies have to be perfect.
QUESTION 10:
Something might be wrong here. Is the signal is "on" or "off" at the time "x"? This is not easy to tell. What is worse, a different amount of noise changes the answer. What can be done about this problem? (Hint: must the value of the signal be known at all times?)
Clocks
Digital systems are built so that the "on" "off" (binary) value is only tested at certain times, giving the wire (or transistor, or...) a chance to change its state between
these times. This is why computer systems have a "clock" to keep all these times synchronized. So faster clocks mean wires can be tested more times per second, and the whole system runs faster. Processor chips (and the computers that contain them) are often described in terms of their clock speed. Clock speed is measured in Hertz, where one Hertz is one clock tick per second. The symbol MHz means mega Hertz, a million clock ticks per second. A 700 MHz Pentium processor checks binary values 700 million times in each second. In between these times values are allowed to change and settle down. The faster a processor chip is, the more times per second values can be tested, and the more decisions per second can be made.
QUESTION 11:
Which is faster, a 400 MHz Pentium processor or a 800 MHz Pentium processor?
Since data of all kinds is stored in computer memory (main and secondary) using the same electronic methods, this means that endless perfect copies can be made of any type of data or program. This idea is that any system of symbols can be translated into bit patterns. An example is how English characters are represented as eight-bit patterns. The agreeement about what patterns represent what characters is called ASCII. The hardware and the software of a computer system (usually) follow this agreement when the data is "text". (You will learn more about this later). Other types of data (non-character data) are represented using other methods.
QUESTION 12:
QUESTION 13:
What about representing things other than the written characters of a language? This is a deep topic, and entire books have been written on it. Here is a very
sloppy discussion: Pick some subject. Use English sentences to describe it. Represent those sentences in ASCII (characters encoded as byte patterns.) Now the subject is represented in binary. If something can be represented in English, then it can be represented in binary. Notice that this says nothing about "meaning" or "understanding." Printed books don't understand their own contents. A digital version of the book (say on CD ROM) doesn't understand the book, either. It mearly holds the information, waiting for a human mind to do the understanding. However the book has been represented as bit patterns. Nobody said that binary representations are easy to use. Some representation methods are very useful for computers (for instance, using binary patterns to represent numbers), others are nearly usless. Much of the work that computer scientists do is figuring out how to represent things using binary in ways that are useful. For example, much work has been done in the last ten years in figuring out how best to represent image and audio data. Important Point: All that computer memory (and other parts) holds is bit patterns. What those bit patterns represent depends on how they are used.
QUESTION 14:
Sometimes people say, "All that a computer can handle is numbers. It doesn't understand anything else." Do you think that this is correct?
What "binary" means. What a "bit" is. The advantages of using binary in a computer. What "analog" means. How thresholds are used. The master clock of a computer. Memory contents as bit patterns.
Back to the main menu. You have reached the end of the chapter.
Bits and Bytes. Kilobytes, megabytes, gigabytes. Main memory and addresses. Secondary memory. Files.
QUESTION 1:
(Educated Guess: ) If you bought a new computer, about how much main memory would you expect it to have: 128 bytes, 64 kilobytes, 4 megabytes, or 64 megabytes? (Hint: Encarta (a multimedia encyclopedia) needs a minimum of 16 megabytes.)
Characteristic
Very closely connected to the processor. Holds programs and data that the processor is actively working with. Used for long term storage. The processor interacts with it millions of times per second. The contents is easily changed. Relatively low capacity. Relatively huge capacity. Fast access. Slow access. Connected to main memory. Holds programs and data. Usually its contents are organized into files.
QUESTION 2:
What do you remember about computer memory? In the table, decide what is true for main memory and for secondary memory. (Click on a button to see if you are correct.)
Bit
In both main and secondary memory, information is stored as patterns of bits. Recall from chapter two what a bit is: A bit is a single on/off value. Only these two values are possible. The two values may go by different names, such as true/false, or 1/0. There are many ways in which a bit can be implemented. For example a bit could be implemented as:
A mechanical electrical switch (like a light switch.) Voltage on a wire. A single transistor (used in main memory). A tiny part of the surface of a magnetic disk. A tiny part of the surface of a magnetic tape. A hole punched in a card. A tiny part of the light-reflecting surface of a CD. Part of a radio signal. Many, many more ways
So the particular implementation of bits is different in main memory and secondary memory, but logically, both types of memory store bits.
QUESTION 3:
(Thought question:) Does the information change when a bit is copied from one form of storage to another? For example, does the information change when a bit implemented as a voltage level on a wire is copied to a tiny part of a disk?
Copied Information
Information stored in binary form does not change when it is copied from one medium (storage method) to another. And an unlimited number of such copies can be made (remember the advantages of binary.) This is a very powerful combination. You may be so accustomed to this that it seems commonplace. But when you (say) download an image from the Internet, the data has been copied many dozens of times, using a variety of storage and transmission methods. It is likely, for example, that the data starts out on magnetic disk and is then copied to main storage of the web site's computer (involving a voltage signal in between.) From main storage it is copied (again with a voltage signal in between) to a network interface card, which temporarily holds it in many transistors. From there it is sent as a electrical signal down a cable. Along the route to your computer, there may be dozens of computers that transform data from an electical signal, into main memory transistor form, then back to an electrical signal on another cable. Your data may even be transformed into a radio signal, sent to a satellite (with its own computers), and sent back to earth as another radio signal. Eventually the data ends up as data in your video card (transistors), which transforms it into a TV signal for your monitor. The point of all of this is that the actual information (in this example the picture) does not change from one media to the next.
QUESTION 4:
Analog data (continuously changing signals) such as on LP records or audio tape also can be copied from medium to medium. Does the information of analog data change when it is copied to a different media?
Byte
Name byte kilobyte megabyte gigabyte terabyte Number of Bytes 1 1024 1,048,576 1,073,741,824 1,099,511,627,776 power of 2 20 210 220 230 240
One bit of information is so little that usually computer memory is organized into groups of eight bits. Each eight bit group is called a byte. When more than eight bits are required for some data, a whole number of bytes are used. One byte is about enough memory to hold a single character. Often very much more than eight bits are required for data, and thousands, millions, or even billions of bytes are needed. These amounts have names, as seen in the table. If you expect computers to be your career, it would be a good idea to become very familiar with this table. (Except that the only number you should remember from the middle column is that a kilobyte is 1024 bytes.) Often a kilobyte is called a "K" and a megabyte is called a "Meg."
QUESTION 5:
Some Hollywood actors have been named after units of memory, for example, Giga Young. Can you think of any others?
Mega Ryan and Tera Garr come to mind. There must be others.
QUESTION 6:
Locations in a digital image are specified by a row number and a column number (both of these are integers). Say that a particular digital image is 1024 rows by 1024 columns, and that each location holds one byte. How many megabytes are in that image? Locations in a digital image are specified by a row number and a column number (both of them integers). A particular digital image is 1024 rows by 1024 columns, and each location holds one byte. How many megabytes are in that image?
Each box in this picture represents a single byte. Each byte has an address. In this picture the addresses are the integers to the left of the boxes: 0, 1, 2, 3, 4, ... and so on. The addresses for most computer memory start at 0 and go up in sequence until each byte has an address. Each byte contains a pattern of eight bits. When the computer's power is on, every byte contains some pattern or other, even those bytes not being used for anything. (Remember the nature of binary: when a binary device is working it is either "on" or "off", never inbetween.) The address of a byte is not part of its contents. When the processor needs to access the byte at a particular address, the electronics of the computer "knows how" to find that byte in memory.
QUESTION 7:
Each byte of main memory has a unique address. If main memory is 4 megabytes large, there will be 4 * 220 addresses.
Each byte of main memory has a unique address. Yes If main memory is 4 megabytes large, there will be 4 * 220 addresses.
Yes
The only thing that can be stored at one memory location is eight bits, each with a value of "0" or "1". The bits at a memory location are called the contents of that location. Sometimes people will say that each memory location holds an eight bit binary number. This is OK, as long as you remember that the "number" might be used to represent a character, or anything else. Remember that what a particular pattern represents depends on its context (ie., how a program is using it.) You cannot look at an arbitrary bit pattern (such as those in the picture) and say what it represents.
QUESTION 8:
(It is customary to show bit patterns with a space every 4 bits. The space is not actually part of the pattern.)
2. It can read a byte from a given location. o The processor gets the bit pattern stored at that location. o The contents of that location are NOT changed. For example, if the processor needs to get the byte stored at location 5, it can read it. It gets the byte "0110 1110" as the data it needs (but location 5 in memory does not change.) Most processors can write (and read) more than a single byte at a time. This speeds things up. But the two operations above are fundamental. You may have heard talk about the new 64-bit processors and 128bit processors. A 64-bit processor can read and write 64/8 = 8 bytes at a time.
QUESTION 9:
Say that later on the processor needs to save the byte "1111 1111" and picks location 7 for this. How will main memory be changed?
When you write a program in Java (or most other languages) you do not need to keep track of memory locations and their contents. Part of the purpose of a programming language is to do these things automatically.
QUESTION 10:
(Review Question:) Where are programs and data kept for long-term storage?
Hard Disks
The hard disk of a computer system records bytes on a magnetic surface much like the surface of audio tape. The recording (writing) and reading of the data is done with a read/write head similar to that used with audio tape. The picture shows one disk and one read/write head at the end of a movable arm. The arm moves in and out along a radius of the disk. Since the disk is rotating it will record data in a circular track on the disk. Later on, to read the data, it must be moved to the right position, then it must wait until the rotating disk brings the data into position. Just as with audio tape, data can be read without changing it. When new data it recorded, it replaces any data that was previously recorded at that location. Unlike audio tape, the read/write head does not actually touch the disk but skims just a little bit above it. Usually the component called the "hard disk" of a computer system contains many individual disks and read/write heads like the above. The disks are coated with magnetic material on both sides (so each disk gets two read/write heads) and the disks are all attached to one spindel. All the disks and heads are sealed into a dust-free metal can. Since the operation of a hard disk involves mechanical motion (which is much slower than electronic processes), reading and writing data is much slower than with main memory.
QUESTION 11:
(Thought Question:) Why does not the read/write head of a hard disk touch its surface?
Files
Hard disks (and other secondary memory devices) are used for long-term storage of large blocks of information, such as programs and data sets. Usually disk memory is organized into files. A file is a collection of information that has been given a name and is stored in secondary memory. The information can be a program or can be data. The form of the information in a file is the same as with any digital information---it consists of bits, usually grouped into eight bit bytes. Files are frequently quite large; their size is measured in kilobytes or megabytes. If you have never worked with files on a computer before you should study the documentation that came with your operating system, or look at a book such as Windows NT for Dummies (or whatever is appropriate for your computer.) One of the jobs of a computer's operating system is to keep track of file names and where they are on its hard disk. For example, in DOS the user can ask to run the program DOOM like this:
C:\> DOOM.EXE
The "C:\>" is a prompt; the user typed in "DOOM.EXE". The operating system now has to find the file called DOOM.EXE somewhere on its hard disk. The program will be copied into main storage and will start running. As the program runs it asks for information stored as additional files on the hard disk, which the operating system has to find and copy into main memory.
QUESTION 12:
Where does a program typically put its results for long-term storage?
QUESTION 13:
In modern computer systems, only the operating system can directly do anything with disk files. How does this: 1. 2. 3. affect the security of the system? affect computer games? affect the ease in creating programs?
(You might not be certain about your answers, but please think about the questions.)
In modern computer systems, only the operating system can directly do anything with disk files. How does this: 1. affect the security of the system? o The security is increased because programs that try to do dangerous or stupid things to files can't. They have to ask the operating system, which will only do safe and sensible things. affect computer games? o Older computer games did their file manipulation themselves without asking the operating system (old DOS was stupid and slow and many application programs ignored it.) Those games won't run on modern computers. affect the ease in creating programs? o Program creation is easier because the work of dealing with files is done by the operating system.
2.
3.
Types of Files
As far as the hard disk is concerned, all files are the same. At the electronic level, there is no difference between a file containing a program and a file containing data. All files are named collections of bytes. Of course, what the files are used for is different. The operating system can take a program file, copy it into main memory, and start it running. The operating system can take a data file, and supply its information to a running program when it asks. Often then last part of a file's name (the extension) shows what the file is expected to be used for. For example, in "mydata.txt" the ".txt" means that the file is expected to be used as a collection of text, that is, characters. With "Netscape.exe" the ".exe" means that the file is an "executable," that is, a program that is ready to run. With "program1.java" the ".java" means that the file is a source program in the language java (there will be more about source programs later on in these notes.) To the hard disk, each of these files is the same sort of thing: a collection of bytes.
QUESTION 14:
What happens when a file is used in a way other than its intended use? For example, what happens if you try to use a word processor on an ".EXE" file?
You have reached the end of the chapter. If you have trouble with your own memory, and need to review a topic, click on it in the list below to go to where it was discussed. To get back here, click on the "back arrow" button of your browser.
Types of computer memory and their characteristics. Bit. Byte, kilobyte, megabyte, gigabyte, terabyte. Multiplication rule for exponents. Picture of main memory. Contents of main memory, Two things that the processor can do with main memory. Picture of a hard disk. Files. Operating system and file i/o.
Back to the main menu. You have reached the end of the chapter.
This chapter first examines the "brain" of the computer system -- the processor. Chapter Topics:
Machine operations and machine language. Example of machine language. Different types of processor chips. High level programming languages. Language translators (compilers.) Language interpreters.
QUESTION 1:
A Pentium Processor
This is the Pentium 90 processor from my 1995 Dell Dimension computer. The actual silicon chip is sealed inside the golden colored metal rectangle. The picture shows the bottom of the Pentium. The many gold fingers are usually pushed into a socket on the main circuit board of the computer.
Those are the only things that a processor can do. It has a small set of tiny electronic operations that it can to perform, and that is all. These little electronic operations are performed one at a time. But millions of them are performed per second. Millions of small operations can add up to a large and useful action. Everything that a processor does are built out of these tiny operations! Luckily, you don't need to know these details to write programs in Java. The purpose of a "highlevel language" like Java is to organize the tiny electronic operations into large, useful units represented by program statements.
QUESTION 2:
(Thought question:) When you click on a hyperlink (such as the next button) your Web browser (a computer program) finds and displays a new page. About how many detailed electronic operations does the processor perform in doing this?
1 10 100 100,000
Machine Instructions
Users and programmers of computers usually don't think about the millions of tiny electronic operations that go on each second. The situation is (very roughly) similar to when you are driving your car. You think about the "big operations" it can perform, such as "accelerate", "turn left", "brake", and so on. You don't think about the valves in your engine opening and closing 24,000 times per minute. Each tiny electronic operations that a processor can perform is called a machine operation. A processor (a "machine") performs these one at a time, but millions of them in a second. A machine instruction consists of several bytes in memory that tells the processor to perform one machine operation. The processor looks at machine instructions in main memory one after another, and performs one machine operation for each machine instruction. The collection of machine instructions in main memory is called a machine language program or (more commonly) an executable program. Don't panic if the above seems incomprehensible. It takes some getting used to. (And to really understand it all takes several courses.)
QUESTION 3:
When they are running, are machine langage programs in main memory along with data?
Machine Operation
Machine Instruction 0000 0000 0000 0001 0000 0010 0000 0100 0000 1000 Stop Rotate bristles left Rotate bristles right Go back to start of program Skip next instruction if switch is off
The toothbrush is wired so that when the switch is turned on, the instructions are performed one at a time, in order, starting at address zero. The program can be restarted at address zero with the instruction 0000 0100. The toothbrush is supposed to rotate the bristles left and right while the switch is on, and stop when the switch is off.
QUESTION 4:
Fill in main memory starting at address 0 with the machine instructions to control the toothbrush. (Please take the time to do this. If you do, you will be able to tell people that the first program you ever wrote was for an electric toothbrush. You do not want to pass up this opportunity).
To help you read the program, here is the list of machine operations:
Machine Instruction 0000 0000 0000 0001 0000 0010 0000 0100 Stop Rotate bristles left Rotate bristles right Go back to start of program Machine Operation
0000 1000
This is, of course, a stupid example. Electric toothbrushes are not controlled by computer processors. And, the machine instructions of actual processors are much more detailed. But the essential ideas of the example are these: A machine language program is a sequence of machine language instructions in main memory. A machine instruction consists of one or more bytes (in the example, only one.) The processor runs a program one machine instruction at a time. All the little machine operations add up to something useful.
If toothbrush user leaves the switch "on" for a while, the program repeats its operations many times. This is how most programs in real computers run--many little operations add up to a useful function, which is then repeated many times.
QUESTION 5:
Will the electric toothbruch stop immediately when the switch is turned off? (Follow through the program to see if this happens.)
Executing Instructions
The word "execute" is often used to mean "perform the machine operation that an instruction asks for." So you can say that "executing the instruction 0000 0000 stops the toothbrush," or "millions of instructions execute per second." "Execute" is also used for an entire program or part of a program: "to execute the program, turn the switch to on." Most machine language programs are made up of instructions that are executed again and again. In the toothbrush program there was an instruction that caused the processor to start the program again from the beginning. In a real computer, millions of instructions execute per second, so something like this is necessary if the 32 megabytes of a typical computer are to hold a program that runs for more than a few seconds. A group of machine instructions that can be repeatedly executed is called a loop. A typical processor is made up of several million transistors, all on one small wafer of silicon called an integrated circuit (also called a chip.) The toothbrush processor could probably be built with just a few hundered transistors. Integrated
circuits are used for other electronic parts of a computer: for example main memory is implemented with memory chips.
QUESTION 6:
Do Apple computers and IBM compatible computers use the same processor chips?
Different Processors
There are many types of processors used in computer systems. You probably know something about the most popular ones such as Intel Corporation's processors (486, Pentium, Pentium II), and the processors used in Apple computers. A computer system is designed around its processor. The other electronics are designed for a particular type of processor. The fundamental difference between (say) an Apple Power Macintosh and a Dell Corporation computer is the processor each is designed around. Different processors have different machine operations. A machine program for a Dell computer (with a Pentium processor) would make no sense to an Apple computer. This is why you ordinarily have to be careful to purchase the correct version of an application for your home computer. If you buy the game Myst, you need to get the version for whatever processor your home computer uses. But there is a version of Myst for both Pentium-based computers and for Apples. How can this be, if the processors perform different machine operations? The answer is that even though the processors are different, the machine operations available on each can be used to build the same things. Both processor types have enough power in their little machine operations so that anything one processor can do with a machine program, the other processor can do with a different machine program. The architecture of a processor is the choices that have been made for its machine operations, how they have been oraganized and implemented, and how it interacts with main memory and other components. Architecture is concerned with the general plan and functions of a processor; it is not much concerned with electronic details. A course in computer architecture is required in most computer science departments.
QUESTION 7:
(Thought question:) Say that you are looking at two different processor chips. The first processor has twice as many types of machine operations as the second chip. Is the first processor necessarily the best one?
The machine operations that correspond to this line will set up a small part of main memory to hold a number, store the number zero there, and arrange things so other parts of the program can use it. It might take a hundred machine operations to do all this. Obviously, it is easier for a human programer to ask for all these operations using "C".
QUESTION 8:
Say that a corporation pays programmers $50 an hour. Will the corporation want programmers to program in machine language or in a high level language?
Source Programs
Programers create programs by writing commands in a high level language. A high level language program consists of lines of text that have been created with a text editor and are kept in a file on the hard disk. For example, here is a complete program in "C" (Java will be discussed later):
#include <stdio.h> main() { int sum = 0; sum = 2 + 2; printf( "%d\n", sum ); }
This program could be saved on the hard disk in a file called addup.c. Like all files, it consists of a sequence of bytes. Since it is a text file, these bytes contain character data. You can edit the file with a text editor and print the file on a printer. It does not contain machine instructions. If the bytes are copied into main memory, they cannot run as a program without some extra work being done. A source program (or source file) is a text file that contains instructions written in a high level language. It can not be executed (made to run) by a processor without some intermediate steps. Usually a source program is translated into a machine language program An application program called a translater takes a source file as input and produces an executable program (machine language program) as output. For example, the "C" program addup.c could be translated into an executable program. The executable program might be called addup.exe and can be saved on the hard disk. Now the executable version of the program can be copied into main memory and executed. The word compile means the same thing as translate. So one can say that a source program is compiled into an executable program.
QUESTION 9:
Say that a source program has been translated into an executable. The executable has been run a few times, and the programer decides to make a change to the program. Where is the change made? To the source program or to the executable program?
Program Translation
Here is a picture that shows what usually happens with programs written in "C" (Java is different; it will be discussed in the next chapter.)
Here is a review of what goes on: 1. The source file is created using a text editor. o It contains instructions in a high level language. o It contains bytes that hold characters. 2. The source file is kept on the hard disk. 3. The source file can not be run by the processor. 4. A translator (compiler) program can translate the source file into an executable file. o The source file remains unchanged; a new executable file is created. o A translator is used for programs written in a specific high level language (like "C") and a specific processor type (like "Pentium"), and only runs under a specific operating system (like "Windows".) 5. The executable file is also kept on hard disk. 6. To run the program, the operating system is told to copy the executable file into main memory and to start it running. The above is what goes on with most languages: Ada, Pascal, C, C++, FORTRAN and others. Java adds a few more steps, which will be discussed in the next chapter.
QUESTION 10:
A source program has been written in the "C" language. The file has been copied onto the hard disk of a Pentium-based computer and onto the hard disk of an Apple Macintosh. What must now be done so that the program can execute on both computers?
On the Pentium: A "C" translator for Pentium processors is used. On the Macintosh: A "C" translator for Macintosh processors is used.
Portability
Ideally, only one program needs to be written in the high level language. That source file can then be translated into several executable files, each containing the correct machine instructions for its intended processor. This is how versions of "Myst" for Pentium computers and Apple computers were made: one source file was created, and it was translated into two different executable files. The idea of using one source file for executables that run on different processors is part of software portability. You would like to write a program just once (in a high level language) and then be able to run it on any computer system by translating it into that systems machine language. Usually, unfortunately, things do not work out that nicely. There are enough little problems so that it takes a substantial amount of human effort to get a program running on a new system. One of the big advantages of Java is that it is automatically portable between computer systems that have Java support. No human effort is involved at all.
QUESTION 11:
Say that a corporation pays programmers $50 an hour to write application programs that will run on both Apple and Intel computers. Will the corporation want programmers to program in Java or in some other high level language?
Interpreter
Programs written in a high level language are never directly executed by the processor. You have already seen one way to execute such a program: use a translator to create a machine language program that can be executed directly. Another way to is to use an interpreter for the language.
An interpreter is a program that acts like a processor that can directly execute a high level language. This is a fairly complicated thought. The figure might help:
In this figure, the source program "program.bas" has been written in BASIC (a programming language) by a programmer with a text editor. It is being interpreted by the BASIC interpreter, which is running on the processor. The BASIC interpreter will read each command in the source program and do what it says. You have probably done this many, many times without realizing it. It is exactly accurate (although an unusual use of the words) to say that the computer game DOOM (or any other game) is an interpreter for the commands that the user enters using the mouse and keyboard. The commands for the game DOOM are not the usual type of commands used in a general purpose programing language, but none the less, they are commands. The set of commands and the rules for how to use them correctly form a programming language for the DOOM interpreter. When DOOM is running in "demo mode" (a sample game played without user input) it is in fact running a program written in the DOOM language. This program is not being directly processed by the Pentium chip in your computer. The DOOM game is interpretting it command by command.
QUESTION 12:
An interpreter runs directly on the processor. What type of instructions must an interpreter consist of?
Virtual Machine
When an interpreter is running a BASIC source program, both the interpreter and the source program are in main memory. The interpreter consists of machine instructions that the hardware can execute directly. The BASIC source program consists of commands in the language BASIC that the interpreter knows. From the perspective of the BASIC program, it looks like the commands in BASIC are being directly executed by some sort of machine. Here is the figure, modified to show this:
This is really the same as the previous figure, but now a box has been drawn around the actual (hardware) processor and the interpreter that it is executing. The combination "looks like" a machine that can directly act upon BASIC source programs. The word virtual is used in situations where software has been used to make something look like the real thing. In this case it looks like we have a machine that can directly execute BASIC, so we can say that we have a BASIC virtual machine.
QUESTION 13:
Do you think that it would also be possible to use a translator to translate a BASIC source program into an executable file (containing machine instructions)?
Speed
The situation with computer languages is somewhat like that with human languages: Translator: takes a complete document in one language and creates a complete document in another language, which can then be used at any time. Interpreter: acts as an intermediate between a speaker of one language and a speaker of another language to make it look like both speakers are talking directly to each other.
Using a human interpreter as an intermediate is slower than conversing directly in a particular language. The same is true with computer language interpreters. The interpreter has to do quite a bit of work to deal with the language it is interpreting. The extra work makes it look like the virtual processor is much slower than the real one.
QUESTION 14:
Is it always important for a program to run as fast as possible? (Hint: take some time to answer this question.)
Machine operations and machine instructions. Executing a program. Differences in types of processor chips. High level programing language. Source program. Program translation. Program interpretation. Portability.
The next chapter will discuss how the language Java fits into the concepts this chapter has discussed.
Back to the main menu. You have reached the end of the chapter.
Hello World program. Java Bytecodes. Java compiler and Java virtual machine. Using Notepad to create a source program. Running a Java program.
These notes are written for JavaTM 2 SDK Standard Edition version 1.3 or higher. The current release is version 1.4.2 (as of June, 2003). Earlier versions will usually work for these notes and may be easier to obtain (perhaps on a CD that came with a book.)
QUESTION 1:
Installing Java
If you already have some version of Java installed on your computer it will almost certainly be sufficient for these notes. You don't need the latest version. To run the current version of Java you need a computer that is running:
Windows 98 or higher, Windows NT or higher, most versions of Unix (including Linux), or a recent Apple.
If you have Windows 95 you will need to install an older version of Java. Java 1.3 will work. These Notes were prepared using Windows NT 4.0 with Java 1.3, but the screen shots are typical of all Windows operating systems. If you are running some other operating system there will be small differences in how you create and run programs, but absolutely no difference in the Java language itself.
The JavaTM 2 Software Development Kit (SDK) is a collection of software available at no charge from Sun Microsystems, Inc. At the time of writing (July 16, 2003) the download is available at java.sun.com. Detailed instructions on how to download it and install it are available at that site. If you have not yet installed Java, get the most recent version. The SDK for Windows comes in a file named j2sdk1_4_2-windows-i586.exe (or a similar name.) This is a 44 megabyte file, which may take hours to download over a modem. Once you have this file install it by clicking on it. This starts an installer program. Then mostly all you do is keep clicking the buttons that accept the default options. If the installation worked you should now have a new subdirectory on your C: drive named j2sdk1.4.2 (or similar).
(The directory jdk1.3.1 in this picture is left over from a previous installation.)
QUESTION 2:
Of course.
Java Documentation
(If you don't know about DOS windows, skip this section.) A simple test is to open a command line window (a DOS window) and CD to C:\j2sdk1.4.2\bin. Type "javac" after the prompt.
C:\j2sdk1.4.2\bin>javac
The java compiler should run, briefly. It will write out about 15 lines of instructions on how to use it. (Details on how to use it come later in this chapter.) While you are at java.sun.com (or later if you don't have time) get the Java documentation. This comes in a file j2sdk-1_4_2-doc.zip. You will have to "un-zip" it after you download it. On most computers un-zipping a file can be started by clicking on the file name. You will end up with a set of web pages (stored on your computer) that describe the features of Java.
QUESTION 3:
When you create a program, do you keep it in the same directory as the compiler?
PATH variable
Usually you create a subdirectory to hold the various program files for a new project. You would like to run the compiler while working in that directory. The Windows operating system uses an environment variable called PATH that is a list of all the subdirectories in which it is to look to find programs. In a DOS window, type "path" after the prompt:
C:\j2sdk1.4.2\bin>path PATH=C:\WINNT\system32;C:\WINNT;.;C:\j2sdk1.4.2\bin
Exactly what you see depends on your OS and what you have done with it. If you don't see C:\j2sdk1.4.2\bin (or similar) in your PATH you will have to edit your PATH variable. How you do this depends on your operating system. Look for detailed instructions on the Sun Web site.
If you can't figure out how to set the PATH variable, then you can put all your programs in C:\j2sdk1.4.2\bin and compile and run them there. This is crude, but it works.
QUESTION 4:
QUESTION 5:
Can the processor of a computer system directly execute source programs written in Java?
This program will be created as a text file using a text editor such as the "NotePad" editor (details on how to do this will come later.) The important thing for now is to understand that it is a file that is saved on the hard disk. The file should be named Hello.java. This file is called a source program. Since the file contains characters (stored as bytes) it can not be directly executed (run) by the computer system. As a text file, you can print it, display it on the monitor, or alter it with a text editor.
QUESTION 6:
(Review of Chapter 4:) What are the two ways that a source program can be run on a computer system?
Bytecodes
Java combines these ideas in a way that will take some explaining. To get the sample program running, it first is translated into bytecodes. A Java bytecode is a machine instruction for a Java processor. The architecture of this processor has been very carefully described by the designers of Java and is available to anyone. To run a Java program on the Java processor, the souce program (the text file) must be translated into bytecodes. Here is a picture of the sample Java program Hello.java being translated into bytecodes. The file of bytecodes (machine language for the Java processor) is called Hello.class.
In this picture, the source program Hello.java is examined by a program called javac running on your computer. The javac program is a compiler (a translator) that translates the source program into a bytecode file called Hello.class.
Important Idea: The bytecode file will contain exactly the same bytecodes no matter what computer system is used. The Java compiler on a Macintosh will produce the exact same bytecodes as the Java compiler on an Intel system.
QUESTION 7:
If you had a hardware Java processor could it run the bytecodes as a program?
The "Java interpreter" in the picture is an executable program that is running on the computer system. Each type of computer system has its own Java interpreter that
can run on that system. The "Actual Processor" is the actual, hardware, processor chip of that computer system. (Another) Important Idea: The Java interpreter running on any computer system "looks like" a hardware Java processor chip. It is a Java Virtual Machine. Any computer system can execute Java bytecode programs if it has a Java interpreter. The Java interpreter has to be specifically written for the specific processor type of the computer system, but once that is done, the computer system can become a Java virtual machine. That is, it looks like a computer with a hardware Java processor chip and can run Java bytecodes. When a Java program is translated into bytecodes, the bytecodes are exactly the same no matter what computer system is used. This means the bytecodes on a Sun computer can be sent to an Intel based computer and they will run without a problem.
QUESTION 8:
Applets
An applet is a Java bytecode program that runs on a Web browser. Most up-todate Web browsers include a Java interpreter. A Web page on a host computer on the Internet can contain instructions that send Java bytecodes to a client computer (like yours) that has asked to view the page. The Web browser on the client runs the Java applet with its built-in interpreter. Applets are used for user interaction, graphics, and animation. Applets will be discussed in later chapters of these notes. For now, let us concentrate on Java programs that get input from the keyboard and write output to the DOS window of the monitor. These are called Java application programs.
QUESTION 9:
Is the Java used to write applets different from that used to write applications?
On an Intel-based computer running Windows, first start up the DOS command prompt. One way to do this is to click on the "Start" button in the lower right of your screen. You should now see a menu of choices similar to below. Look for the "MS DOS" Icon:
The more recent the Windows system, the harder it is to find the command prompt. If you don't see it at first, click on "Programs" and look futher. When you find it, click on the "MS DOS" icon to start a command interpreter window.
QUESTION 10:
Will you see exactly the same things on your computer system?
This prompt means that the files you create will automatically go onto the hard disk in the subdirectory C:\WINNT\System32. (A subdirectory is a section of the disk that has a name. A subdirectory can hold many files.) You should not create files in this subdirectory. You will probably get a prompt that starts out in some other subdirectory. It doesn't matter where you start out because you can always move to where you want to be using the CD command. For now, let us create a Java program in the C:\Temp directory. To get to this directory type the command:
cd \Temp
Type the command in after the DOS prompt (as above). The prompt changes to show the current default directory.
QUESTION 11:
Starting Notepad
The text editor we will use is called "Notepad." It comes with Microsoft operating systems. Click on the "Start" button in the lower left, then on "Programs" then on "Accessories", and then on "Notepad". As you might expect, different versions of Windows put Notepad in different places. You may have to hunt.
After clicking on the icon, Notepad starts. Another way is to start it from the DOS prompt:
C:\TEMP> notepad C:\TEMP>
QUESTION 12:
Notepad
Once Notepad is running, just type in the program. Here is Notepad with the sample program:
To enter characters, just type them. You can move around the text using the mouse or arrow keys. To delete mistakes, use the "backspace" key or the "delete" key. To start a new line, just hit "Enter". In typing in the program, you DO have to get upper and lower case letters, and all punctuation exactly correct. You do not have to get the spaces exactly correct.
Now you need to save the file to the hard disk. One of the selections in the menu bar at the top of the Notepad window is used to do this.
QUESTION 13:
Which of the menu selections (in the menu bar at the top of the Notepad window) do you suppose is used to save the file?
When you see it, click on the "Temp" directory to say that it is where you wish to save your program. The "Temp" directory is intended for temporary files and will usually be full of many different files.
QUESTION 14:
If you save the file in a different directory than the one being used for the DOS window, will there be a problem?
Fussy, bothersome, irksome, irritating details. Yes, I know... Some people actually like this stuff. But if you can drive a car you can do this. It might take some practice.
QUESTION 15:
So, finally your Java program source file is saved. What must you do to run it?
Compile it into Java bytecodes, then run the bytecode with the Java interpreter.
To compile the source file (thereby producing a file of bytecodes) enter the command javac Hello.java.
C:\TEMP>javac Hello.java compiling: Hello.java
... then the PATH environment variable has not been set correctly. Either go back and figure out how to do that, or use the directory C:\j2sdk1.4.2\bin instead of C:\TEMP. Finally, to run the program, enter the command java Hello.
C:\TEMP>java Hello Hello World! C:\TEMP>
QUESTION 16:
After all of this, what did the Java program actually do?
QUESTION 17:
Example Java program. Java bytecodes. Java virtual machine. Applets. Starting the command prompt. Starting Notepad. Saving the source code to a file. Running the program.
Small example programs. Names for source files and class files. Syntax errors. Bugs. The Edit, Compile, and Run cycle Matching braces. Neat indenting.
QUESTION 1:
(Review:) What role in Java programming does each of the following files play?