CPSC 124, Fall 2005
Answers to Quiz #1


Question 1: Explain the difference between a high-level programming language and machine language.

Answer: In a high-level programming language, instructions are written in a form that is human-readable, because it is something like ordinary human language. In machine language, instructions are coded as binary numbers. A computer cannot understand high-level programming languages directly -- they must be translated into machine language before they can be executed. The computer can directly execute a program that is written in its machine language.


Question 2: What is done by the Java statement

            System.out.println(totalCost);

Answer: This command displays the value of the variable named totalCost in a console window. The value is followed by a carriage return. (Although the value is most likely the "total cost" of something, that is only an assumption. All we can say for sure is that the value of the variable, whatever it is, will be displayed.)


Question 3: One of the commands that you used in the lab this week was javac. What does the javac command do?

Answer: The javac command is used to compile a .java file, which is written in the high level programming language, Java. The Java code is compiled into a .class file that contains Java "bytecode." (Java bytecode is a machine language for the Java virtual machine. on a real computer, it has to be run through an interpretor. This is done using the java command.)


Question 4: One of the components of a computer is the CPU. What is the function of the CPU?

Answer: The CPU is the component of the computer that actually executes machine language instructions. The CPU continually fetches instructions from memory and executes them.


Question 5: A "GUI" (Graphical User Interface) uses things like windows, menus, buttons, text-input boxes, and so on, to let the user interact with the computer. What do these things have to do with object-oriented programming?

Answer: Each interface "object" on the screen is represented by a software object in a program.


Question 6: What is a subroutine?

Answer: A subroutine is a set of instructions for performing some task that has been chunked together and given a name. Once a subroutine exists, it is only necessary to call it by name in order to have it perform its task. You can use a subroutine without understanding how it works internally.


Question 7: Explain what is meant by the syntax of a programming language.

Answer: Syntax refers to the "grammar" rules of the prgramming language, the set of rules that specify what is legal in a program. Syntax refers to the form of the language rather than to its meaning. A program that is syntactically correct can be compiled without error.


David Eck, 6 September 2005