Midterm Exam

home Contents Index Prev Next

Java Programming CS410x Show Work

Please write your name ( print please ):

Please write your Student ID#:

Fill in the blank with the correct answer:

1. Object oriented questions ( 35 points)


a) If the class Alpha inherits from the class Beta, class Alpha is called the class and class Beta is called the class.

b) A method call resolved at run time is referred to as binding.

c) A method call resolved at compile type is referred to as binding.

d) A "has a" relationship between classes represents and an "is a" relationship represents .

e) An object of a class can be treated as an object of its corresponding class.

f) If a class contains one or more abstract methods, it is an class.

g) Three member access specifies are , and .

2. (5 points) A java program file must end with the file extension.

3. (5 points) When a java program is compiled, the file produced by the compiler ands with the file extension.

4. (5 points) Identify and correct the errors in the following statement:
if ( c < 7 );
g.drawString(" c is less than 7", 25, 25);

answer:
5. (5 points) What is wrong with the following while repetition structure:
while(z>=0)
sum += z;
answer:
6. (10 points) For the following program, state the scope (either class scope or block scope) of each of the following elements.

a) the variable x.

b) the variable y.

c) the methodcube.

d) the method paint.

e) the variable yPos.
Public class Cube Test extends Applet {
int;
public void point ( Graphics g ) {
int yPos = 25;
for (x =1; x <= 10; x++){
g.drawString(cube(x), 25, yPos);
yPos += 15;
}
}
public int cube (int y) {
return y * y * y;
}
}

7. (10 points)Answer the following questions regarding an array called fractions.

a) Declare an array with arraySize elements of type float and initialize the elements to 0;

b) name the fourth element from the beginning of the array.

c) Refer to array element 4.

d) Assign the value 1.667 to array element 9.

e) Sum all the element of the array using a for repetition structure. Define the integer variable x as a control variable for the loop.

8. (10 points) Object based fill-in the blank questions:

a) Members of a class specified as are accessible only to methods of the class.

b) The keyword introduces the class_name.

c) The operator dynamically allocates memory for an object of a specified type and return a to that type.

d) The keyword before an instance variable makes it available to all instances of that class.

e) A method declared as static cannot assess class members.

9. (15 points) Fill in the blank

a) RGB is short for , and .

b) The return type of getName is .

c) GUI is an acronym for .

if you have comments, add them in the following text box:

To send the information, click the Submit button.
To clear your entries and start over, click the Reset button.

Cover page

home Contents Index Prev Next

UBLOGO Last Update: 11/03/96
Copyright © 1996 - Douglas Lyon
Lyon@cse.bridgeport.edu