QMCS280, Spring, 1999
Exam 1
Name: ____________________________________ Date: ____________________
2. Circle the term that best describes the situation whereby previously written programs are rarely used in new systems.
a. Each problem viewed as unique
b. No leverage of existing code
c. Large projects suffer most
d. Creeping functional change
3. Briefly explain what "scenarios" are and what use they have in Object Oriented systems.
4. Circle the correct answer. Which of the following is a reason to build a model:
a. You can test before building
b. It can be used as a communications tool
c. You can visualize what it will look like
d. All of the above
5. Briefly explain the difference between a Class and an Object:
6. Briefly explain what Inheritance is in Object Oriented programming:
7. Circle the correct answer. Which of the following terms means one million bytes:
a. Kilobyte
b. Megabyte
c. Gigabyte
d. Terabyte
8. Main computer memory that requires electricity to maintain its contents is called ______________ _____________ _____________, or the acronym _______.
9. The common measurement of the CPUs system clock speed is ____________________ which means one million clock ticks per second.
10. Generally, there are two kinds of Java programs. Name each kind and briefly describe the differences between the two.
11. For each of the following lines of Java code, indicate what the value for the variable named would be:
Value
int able = 17 + 5 / 2 _____
int baker = 17.0 + 5 / 2.0 _____
float charlie = 17.0 + 5.0 / 2 _____
int dog = 17 + 5 % 2 _____
int eagle = (17 + 5) % 2 _____
12. Briefly explain the difference between the two Java statements "System.out.print()" and "System.out.println()":
13. The Java compiler produces ____________________ and not machine language.
14. Circle the correct answer. Which of the following is not a primitive data type in the Java language:
a. int
b. char
c. string
d. float
e. double
f. boolean
15. Briefly explain the difference between using the wrapper class for a primitive data type (e.g. Integer) versus using the primitive data type (e.g., int):
16. For each of the following loops write in the number of times the loop will be executed. Note that zero and infinite are potentially valid answers:
a. ____________
int count = 0;
int number = 1;
while (count <= number)
System.out.println("Here I go again");
b. ____________
int count = 0;
in number = 1;
while (count > number)
System.out.println("And once again");
number = number + 1;
c. _____________
int count = 5;
int number = 1;
while (count > number) {
System.out.println("And still another time");
number = number + 1;
}
17. Circle the correct answer. Which of the following is not true of "if" statements in Java?
a. An if statement doesn't have to have an else clause
b. If statements can only be nested three deep
c. The statement following the if can be a block of statements
d. The statement following the else can be a block of statements
18. Briefly explain what is meant by "state" and "behaviors" of objects.
19. What would be the output of the following Java code segment:
String quote = "Now is the time for all good persons…";
System.out.println(quote.indexOf('w'));
_________________
20. Briefly explain the difference between what a primitive data type variable name points to in memory versus what an object's variable name points to:
21. Fill in the blank. What type of value will be returned by the following method:
public double doSomething(String s, integer i)
_______________________
22. Briefly explain what a "constructor" is in Java.
23. Briefly explain the difference between the modifier "public" and the modifier "private" when they are applied to variables within a Class:
Hands On:
I. Write a complete Java application that will prompt the user for two numbers and then print out the sum, difference, and product of those two numbers.
II. Write a Java class with the following characteristics:
1. Its name is GPA
2. Its constructor will accept one double for the number of grade points, one
double for the number of credits, and one String for the student name.
3. It has methods to a) add additional grade points and credits, b) compute and
return the grade point average, and c) print the information
Write an application that creates an object of the GPA class and exercises its methods.