




Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





Fall 2006 Form A Page 1 of 8
Failure to read and follow the instructions below may result in severe penalties. Failure to adhere to these directions will not constitute an excuse or defense.
Name (print: Last name, First)
VT Email: (print: campus email address)
Circle Lecture section: MW 9:05 MW 10:
Circle Lab section: Thur 5:00 (McB 118)
Fri 12:10 (Torg 1080) Fri 2:10 (Torg 1080)
Pledge: On my honor, I have neither given nor received unauthorized aid on this examination.
Fall 2006 Form A Page 2 of 8
1) In order for a Java class to receive event messages as defined in the Eventful Java objectdraw library which of the following must be extended?
WindowToolKit 2) objectdraw
FrameControl 4) AbstractWindow
Canvas 6) none of these
For the next two questions use the following responses:
2) Consider the following Java objectdraw code segment:
new FramedRect( 10, 10, 100, 100, canvas ); new Line( 60, 110, 60, 10, canvas ); new Line( 110, 60, 10, 60, canvas );
Which of the above figures would represent a scaled down representation of the graphics drawn by the above code?
3) Consider the following Java objectdraw code segment:
new Line( 100, 100, 0, 200, canvas ); new Line( 100, 100, 200, 200, canvas ); new Line( 0, 200, 100, 300, canvas ); new Line( 100, 300, 200, 200, canvas ); new Line( 200, 200, 0, 200, canvas ); new Line( 100, 300, 100, 100, canvas );
Which of the above figures would represent a scaled down representation of the graphics drawn by the above code?
Fall 2006 Form A Page 4 of 8
For the next two questions use the following responses:
7) Consider the following Java objectdraw code segment:
FilledRect rect = new FilledRect( 10, 10, 100, 100, canvas ); rect.setColor( Color.GRAY ); new Line( 30, 30, 200, 30, canvas ); new FilledOval( 50, 50, 100, 100, canvas ); Text txt = new Text( "Text Label", 110, 110, canvas ); txt.setColor( Color.WHITE );
Which of the above figures would represent a scaled down representation of the graphics drawn by the above code?
8) Consider the following Java objectdraw code segment:
FilledRect rect = new FilledRect( 10, 10, 100, 100, canvas ); rect.setColor( Color.GRAY ); rect.sendToBack(); Line lin = new Line( 30, 30, 200, 30, canvas ); lin.sendBackward(); FilledOval oval = new FilledOval( 50, 50, 100, 100, canvas ); oval.sendToBack(); Text txt = new Text( "Text Label", 110, 110, canvas ); txt.setColor( Color.WHITE ); txt.sendToBack();
Which of the above figures would represent a scaled down representation of the graphics drawn by the above code?
Text Label
Text Label
Fall 2006 Form A Page 5 of 8
9) Consider the following Java objectdraw code:
Location origin = new Location( 0, 0 ); Location originAlias = origin;
boolean ques9 = ( origin == originAlias );
What value is assigned to the variable ques9 by the above code?
10) Consider the following Java objectdraw code:
Location origin = new Location( 0, 0 ); Location unit = new Location( 1, 1 ); unit.translate( -1, -1 );
boolean ques10 = ( origin == unit);
What value is assigned to the variable ques10 by the above code?
11) Consider the following Java objectdraw code:
Location origin = new Location( 0, 0 ); Location unit = new Location( 1, 1 ); unit.translate( -1, -1 );
boolean ques11 = origin.equals(unit);
What value is assigned to the variable ques11 by the above code?
Fall 2006 Form A Page 7 of 8
21) Consider the following Java code:
int A = 0, D = 5; if (R <= T) D = A - 1; else A = 1;
Which of the following code fragments is equivalent to the code above? "Equivalent" means that each code fragment would assign the same values to A and D as the code given above, no matter what the initial values for the variables R and T were.
int A = 0, D = 5; 2) int A = 0, D = 5; if (R > T) if (R >= T) A = 1; A = 1; else else D = A - 1; D = A - 1;
int A = 0, D = 5; 4) int A = 0, D = 5; if (R > T) if (R < T) A = 1; A = 1; if (R <= T) if (R > T) D = A - 1; D = A - 1;
all of the above 6) 1 and 2 only 7) 1 and 3 only
2 and 4 only 9) none are equivalent
22) What is the value printed for the variable delta if the following code is executed?
int delta = 0, x = 3; if ( x / 2 == 1 ) delta = delta + x; x--; if ( x / 2 == 0 ) delta = delta + x; x--; if ( x / 2 == 0 ) delta = delta + x;
System.out.println( "delta = " + delta );
23) Consider the following Java code:
int i = -1, j = 0, k = 1;
boolean b = ( ( i <= j ) || ( k >= j ) );
How many relational operator comparisons are executed by the above code?
Fall 2006 Form A Page 8 of 8
The area of a triangle with sides A, B and C is given by Heron's Formula:
Given the following Java variable declarations:
double area, s, a, b, c;
24) Assume that all of the above variables have been assigned values. Which one of the following two-line code segments accurately describes the correct computation of the area of the triangle represented by sides with lengths equaling the values stored in the variables a, b & c?
s = ( a + b + c ) / 2; area = sqrt( s * (s - a) * (s - b) * (s - c) );
s = ( a + b + c ) / 2; area = Math.sqrt( s (s - a) (s - b) (s - c) );
s = ( a + b + c ) / 2; area = sqrt( s (s - a) (s - b) (s - c) );
s = ( a + b + c ) / 2; area = Math.sqrt( s * (s - a) * (s - b) * (s - c) );
None of the above
Suppose a triangle has sides A, B and C, and assume C is the longest side, say:
Then:
Given the following Java variable declarations:
double a, b, c; boolean right;
25) Assume that all of the above variables have been assigned values. Which one of the following expressions correctly determines if the triangle represented by sides with lengths equaling the values stored in the variables a, b & c is a right triangle?
Triangle is: If: Acute C^2 < A^2 + B 2 Right C^2 = A^2 + B 2 Obtuse C^2 > A^2 + B 2