CPSC 124, Fall 1996

Quiz Number 1

This is the first quiz given in CPSC 124: Introductory Programming, Fall 1996. See the information page for that course for more information.

The answers given here are sample answers that would receive full credit. However, they are not necessarily the only correct answers.

Question 1: The basic operation of a computer's CPU is the "fetch-and-execute cycle." What is the fetch-and-execute cycle? What happens during the fetch-and-execute cycle?

Answer: The fetch-and-execute cycle is the way the CPU of a computer executes programs written in machine language. The CPU fetches a machine language instruction from RAM, where the program is stored. Then it executes that instruction. Then, it fetches the next instruction and executes it. And so on, indefinitely.

Question 2: Explain what is meant by an "asynchronous event." Give some examples.

Answer: An asynchronous event is one that occurs at an unpredictable time outside the control of the program that the CPU is running. It is not "synchronized" with the program. An example would be when the user presses a key on the keyboard or clicks the mouse button. (These events generate "interrupts" that cause the CPU to interrupt what it is doing and to take some action to handle the asynchronous event. After handling the event, the CPU returns to what it was doing before it was interrupted.)

Question 3: What is the difference between a "compiler" and an "interpreter"?

Answer: Compilers and interpreters have similar functions: They take a program written in some programming language and translate it into machine language. A compiler does the translation all at once. It produces a complete machine language program that can then be executed. An interpreter, on the other hand, just translates one instruction at a time, and then executes that instruction immediately. (Java uses a compiler to translate java programs into Java Bytecode, which is a machine language for the imaginary Java Virtual Machine. Java Bytecode programs are then executed by an interpreter.)

Question 4: Java is a "platform-independent language." What does this mean?

Answer: A Java program can be compiled once into a Java Bytecode program. The compiled program can then be run on any computer that has an interpreter for the Java virtual machine. Other languages have to be re-compiled for each platform on which they are going to run. The point about Java is that it can be executed on many different types of computers without being recompiled.

Question 5: What is the "Internet"? Give some examples of how it is used. (What kind of services does it provide?)

Answer: The Internet is a network connecting millions of computers around the world. Computers connected to the Internet can communicate with each other. The Internet can be use for Telnet (which lets a user of one computer log onto another computer remotely), FTP (which is used to copy files between computers), and the World Wide Web (which lets a use view "pages" of information published on computers around the world.

David Eck