CPSC 124, Spring 2017: Sample Answers to Quiz #1
These are sample answers only. Often, answers that are less
detailed than the ones given here can still receive full credit.
Question 1. 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?)
Answer. Main memory consists of a numbered sequence of locations. Each location holds an 8-bit binary number. A location has an address, which is its numerical position in the list. (For example, a variable has an address, which tells where in memory the value of that variable is stored.)
Question 2. What is accomplished by the following statement in a Java program?
Answer. This is a declaration statement. It creates a variable named count of type int. That is, the value of count will be a 32-bit integer.
Question 3. What is accomplished by the following statement in a Java program?
answer = a + b;
Answer. This is an assignment statement that stores a value into a variable. In this case, the value is computed by getting the values of two variables, a and b, from memory, adding those values, and storing the resulting answer in the variable named answer.
Question 4. What is accomplished when the command javac Foo.java is used on the command line?
Answer. "Foo.java" must be the name of text file that contains Java source code. This command compiles the Java source code. If there are no errors in the code, then the result is a file named Foo.class that contains the compiled program. That is, the Java code has been translated into the machine language of the Java Virtual Machine. Once a Java program has been compiled by the javac command, it can be run by using the java command.
Question 5. Name three different primitive data types in Java. (Just list them.)
Answer. The answer can be any three of the following:
double float int long char short boolean byte
[Note that String is not a primitive type.]