CPSC 124, Spring 2021: Sample Answers to Quiz #1
These are sample answers only.
Question 1. What is a CPU (Central Processing Unit)?
Answer. The CPU is the part of the computer that actually executes machine language instructions.
Question 2. An important part of a computer is the main memory (or RAM), which holds programs and data. What is the structure of main memory? (What is it made up of? What does it "look like?")
Answer. The main memory of a computer consists of a numbered sequence of locations, holding binary numbers. Each location stores one byte (that is, eight bits). The number of a location is called its address and is used to refer to a particular value in memory.
Question 3. What is a significant difference between a machine language and a high-level programming language? [Several answers are possible.]
Answer. Some possible answers...
- Machine language is executed directly; high-level language has to be translated into machine language before it can be executed.
- Machine language is written in binary numbers; high-level language is written in a language closer to human language.
- Machine language instructions only do very simple things; high-level langauge instructions can be more complex.
Question 4.
What is accomplished if the command javac MyProg.java
is used
on the command line?
Answer.
MyProg.java must be a program written in the Java programming language. This command
checks the program for syntax errors and, if there are no errors,
compiles that program, producing the
file MyProg.class, which contains the program translated into the machine language
of the Java Virtual Machine. The program can then be run with the command
java MyProg
.
Question 5. What does the following Java statement mean? (What does it accomplish? What are "answer", "x", and "y"?)
Answer. This is an assignment statement; answer, x, and y must be variables that have been declared earlier in the program. When the computer executes this statement, it reads the values of the variables x and y from memory, adds those values, and stores the result of the computation in the variable answer.