Download presentation
Presentation is loading. Please wait.
Published byZoe McKenzie Modified over 8 years ago
1
Test Review
2
General Info. All tests will be comprehensive. You will be tested more on your understanding of code as opposed to your ability to write code. There will be multiple choice and true/false questions. Studying this review is not enough; you are responsible for all material covered in the lecture notes.
3
Test Review Which statement is not true of a variable declaration? Choose one answer. 1.The declaration must be made before the variable is used. 2.The declaration must give a name and a data type for the variable. 3.The declaration must give an initial value to the variable. 4.A variable cannot be used in a program unless it has been declared.
4
Test Review Examples of primitive data types are (Choose one answer.) 1.boolean, int, float, double, byte, and character 2.blean, int, float, byte, double, and char 3.boolean, int, floating, byte, double, and character 4.boolean, int, float, byte, double, and char
5
Test Review Write a statement that declares a variable to store a small number with a fractional (i.e., decimal) component. Write a statement that declares a variable to store a character.
6
Test Review What is the meaning of i++ ? What is the value of each of the following expressions: – 1 + 2 * 5 / 2 –1 < 2 && 3 * 6 < 8 –(1 + 5) % 3
7
Test Review Write a boolean expression that represents the following English statement: The number 10 is greater than 1 but less than 20.
8
Test Review Will these programs print the same thing? int x = random(500); if (x <= 100) { rect(33, 33, 34, 34); } else if (x >= 300) { line(50, 0, 50, 100); } else if (x >= 400) { ellipse(50, 50, 36, 36); } int x = random(500); if (x <= 100) { rect(33, 33, 34, 34); } if (x >= 300) { line(50, 0, 50, 100); } if (x >= 400) { ellipse(50, 50, 36, 36); }
9
Test Review What will be printed by the following code segment? for (int i = 0; i<10; i=1) { print(i + " "); }
10
Test Review What is the test expression so that the following loop prints the line: 0 1 2 3 4 int count = 0; while ( ___________ ) { print( count + " " ); count = count + 1; }
11
Test Review What must the initialization be so that the following fragment prints out the integers -3 -2 -1 ? for ( _______; j < 0; j++ ) println( j );
12
Test Review What must be added so that the following code prints out the even integers 0 2 4 6 8 10? for ( int j = 0; j <= 10; _______ ) println( j );
13
Test Review What would this program draw? size(400,400); smooth(); background(150); for(int x = 0; x < width; x += 40) { rect(x, 0, 10, 10); }
14
Test review Will the following program run? If not, why? void setup() { int x = 10, y = 10; size(400,400); smooth(); background(150); } void draw() { rect(x, y, 20, 20); }
15
Test Review How many functions are called in the program below? int x = 10, y = 10; void setup() { size(400,400); smooth(); background(150); } void draw() { rect(x, y, 20, 20); ellipse(x, y, 30, 30); }
16
Test Review How many functions are written in the program below? int x = 10, y = 10; void setup() { size(400,400); smooth(); background(150); } void draw() { rect(x, y, 20, 20); ellipse(x, y, 30, 30); }
17
Test Review What will this program draw? void setup() { size(400,400); smooth(); background(150); } void draw() { mysteryShape(); } void mysteryShape() { int w = 30, h = 20; rect(width/2, height/2, w, h); }
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.