CPSC 124, Winter 1998

Quiz Number 1


This is the first quiz given in CPSC 124: Introductory Programming, Winter 1998. 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: One of the components of a computer is its CPU. What is a CPU and what role does it play in a computer?

Answer: The CPU, or Central Processing Unit, is the active part of the computer. Its function is to execute programs that are coded in machine language and stored in the main memory (RAM) of the computer. It does this by repeating the fetch-and-execute cycle over and over; that is, it repeatedly fetches a machine language instruction from memory and executes it.


Question 2: A program that is written in the Java programming language must be compiled before it can be executed. Why is this true? What does the compiler do with the Java program?

Answer: A computer can only directly execute a program if it is expressed in the machine language of that particular type of computer. Programs written in a high-level language must be translated into machine language before they can be executed. A compiler is a program that takes a high-level language program and translates it into an equivalent machine language program. Java is a bit unusual in that a Java compiler translates programs written in Java into "Java bytecode", which is not the machine language for any existing computer. A computer that needs to execute a Java bytecode program uses an interpreter to execute the program.


Question 3: 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 computer. An ordinary program that just proceeds step-by-step cannot easily deal with such events, so they are handled in a special way. When an asynchronous event occurs, the program that is being executed is interrupted while the computer responds to the event. Examples of asynchronous events are when the user presses a key on the keyboard, when the user moves the mouse, or when data arrives over a network connection.


Question 4: What is a variable? (There are four different aspects associated with variables in Java. Try to mention all four aspects in your answer. Hint: One of the aspects is the variable's name.)

Answer: A variable is a memory location that has been given a name so that it can easily be referred to in a program. The variable holds a value, which must be of some specified type. The value can be changed during the course of the execution of the program.


Question 5: What is HTML? What is it used for?

Answer: HTML, or HyperText Markup Language, is a language that is used to create Web pages. An .html file contains a description of the contents of a Web page, written in HTML. When you click on a link in Netscape, your computer downloads an .html file, and it displays the page that is described in the .html file.


David Eck, 15 January 1998