Computer Science Exam Study Guide: Data Types, Drawing, Conditions, Loops, Arrays

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/93

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 7:58 PM on 6/17/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

94 Terms

1
New cards

What is a variable?

A named space in a computer's memory used to store a value.

2
New cards

What are the 7 primitive data types in Java/Processing?

int, double, long, short, byte, float, boolean, char

3
New cards

How many bits does int use? What range?

32 bits. Stores values from about -2.1 billion to 2.1 billion.

4
New cards

How many bits does long use?

64 bits

5
New cards

How many bits does short use?

16 bits

6
New cards

How many bits does byte use?

8 bits

7
New cards

What is double used for?

Decimal numbers, 64 bits

8
New cards

What is float used for?

Decimal numbers, 32 bits (less precise than double)

9
New cards

What is boolean?

1 bit — stores only true or false

10
New cards

What is char?

Single 16-bit character (one letter, symbol, etc.)

11
New cards

What are primitive data types?

The basic built-in types of a programming language.

12
New cards

What is a non-primitive data type?

Data types made up of multiple primitive values — more complex.

13
New cards

Is String a primitive data type?

No. String is non-primitive.

14
New cards

Is int a primitive data type?

Yes.

15
New cards

Is boolean a primitive data type?

Yes.

16
New cards

What's wrong with this code: `int x = 3.5;`?

You can't store a decimal in an int. Should be `double x = 3.5;`.

17
New cards

What's wrong with this code: `String name = 'Sai';`?

Strings use double quotes, not single.

18
New cards

What's wrong with this code: `char letter = 'A';`?

char uses single quotes. Should be `char letter = 'A';`.

19
New cards

Which data type would you use to store someone's age?

int

20
New cards

Which data type would you use to store a price like $9.99?

double or float

21
New cards

Which data type would you use to store whether a light is on or off?

boolean

22
New cards

What does size(width, height) do in Processing?

Sets the size of the sketch window in pixels.

23
New cards

What does background(r, g, b) do?

Sets the background colour of the sketch using RGB values.

24
New cards

What does fill(r, g, b) do?

Sets the fill colour for shapes drawn after it.

25
New cards

What does stroke(r, g, b) do?

Sets the outline/border colour of shapes.

26
New cards

What does noFill() do?

Removes the fill so shapes are transparent inside.

27
New cards

What does noStroke() do?

Removes the outline from shapes.

28
New cards

What does ellipse(x, y, w, h) do?

Draws an ellipse.

29
New cards

What does rect(x, y, w, h) do?

Draws a rectangle.

30
New cards

What does line(x1, y1, x2, y2) do?

Draws a line from point (x1, y1) to point (x2, y2).

31
New cards

What does triangle(x1,y1,x2,y2,x3,y3) do?

Draws a triangle using three coordinate points.

32
New cards

What is setup() used for in Processing?

Runs once when the sketch starts.

33
New cards

What is draw() used for in Processing?

Loops continuously (like a game loop).

34
New cards

What does frameRate(n) do?

Sets how many times per second draw() runs.

35
New cards

What does mouseX and mouseY do?

Track the current position of the mouse.

36
New cards

What does println() do in Processing?

Prints a value to the console.

37
New cards

What's wrong with this code: `ellipse(50, 50, 30);`?

ellipse() needs 4 arguments, not 3.

38
New cards

What's wrong with this code: `void setup { size(500, 500); }`?

Missing parentheses after setup.

39
New cards

Top-left corner of the window.

In Processing, where does (0,0) start?

40
New cards

What is a boolean expression?

A statement that can only have two answers: true or false.

41
New cards

Give 3 examples of boolean expressions.

`5 > 3` (true), `10 == 7` (false), `score >= 750`.

42
New cards

What does == mean?

Checks if two values are equal.

43
New cards

What does != mean?

Not equal to.

44
New cards

What does && mean?

AND — both conditions must be true.

45
New cards

What does || mean?

OR — at least one condition must be true.

46
New cards

What does ! mean?

NOT — reverses/flips the boolean value.

47
New cards

What is an if statement?

The most basic conditional.

48
New cards

What is the structure of an if statement?

if (condition) { // code runs if true }

49
New cards

What does else if do?

Tests a second condition if the first if was false.

50
New cards

What does else do?

Runs if all previous conditions were false.

51
New cards

Yes

Is `5 > 3` a boolean expression?

52
New cards

Is `score = 100` a boolean expression?

No — that's assignment. A boolean expression would be `score == 100`.

53
New cards

What's wrong with this code: `if x > 5 { println("big"); }`?

Missing parentheses around the condition. Should be `if (x > 5)`.

54
New cards

What's wrong with this code: `if (x = 10) { println("ten"); }`?

Single `=` is assignment, not comparison. Should be `==`: `if (x == 10)`.

55
New cards

What does this evaluate to: `!(5 > 3)`?

false — because 5 > 3 is true, and NOT flips it to false.

56
New cards

What does this evaluate to: `(3 > 1) && (10 < 5)`?

false — because the second condition (10 < 5) is false, and both must be true for &&.

57
New cards

What does this evaluate to: `(3 > 1) || (10 < 5)`?

true — because the first condition is true, and || only needs one to be true.

58
New cards

What is a loop?

A block of code that repeats multiple times until a condition is no longer met.

59
New cards

What are the three types of loops in Java/Processing?

for loop, while loop, do-while loop.

60
New cards

What is the structure of a for loop?

`for (initialization; condition; update) { // code }`.

61
New cards

What does each part of a for loop do?

Initialization — sets starting value. Condition — checked before each loop. Update — runs after each loop (usually increments).

62
New cards

What is a while loop?

Repeats as long as a condition is true. Checks the condition BEFORE running.

63
New cards

What is a do-while loop?

Runs the code FIRST, then checks the condition. Always executes at least once.

64
New cards

What does this loop print: `for (int i = 0; i < 5; i++) { println(i); }`?

0, 1, 2, 3, 4 (stops before 5).

65
New cards

What is an infinite loop?

A loop that never stops because the condition is always true. Usually a bug.

66
New cards

What's wrong with this code: `for (int i = 0; i < 10; i--) { println(i); }`?

i-- decrements i, so it goes -1, -2, -3... forever. Should be `i++`.

67
New cards

What's wrong with this code: `int i = 0; while (i < 5) { println(i); }`?

i never changes — infinite loop. Need to add `i++;` inside the loop.

68
New cards

What does break do in a loop?

Immediately exits the loop.

69
New cards

What does continue do in a loop?

Skips the rest of the current iteration and goes to the next one.

70
New cards

How many times does this loop run: `for (int i = 1; i <= 10; i++) { }`?

10 times (i goes 1, 2, 3... 10).

71
New cards

How many times does this loop run: `for (int i = 0; i < 10; i++) { }`?

10 times (i goes 0, 1, 2... 9).

72
New cards

A collection of multiple values of the same data type stored together under one variable name.

What is an array?

73
New cards

Is an array a primitive or non-primitive data type?

Non-primitive.

74
New cards

How do you declare an array of 5 integers in Java/Processing?

`int[] numbers = new int[5];`.

75
New cards

How do you declare and fill an array at the same time?

`int[] numbers = {10, 20, 30, 40, 50};`.

76
New cards

How do you access the first element of an array?

`numbers[0]` — arrays are zero-indexed, so the first element is index 0.

77
New cards

How do you access the last element of an array with 5 elements?

`numbers[4]` — index goes 0, 1, 2, 3, 4.

78
New cards

What is the length property of an array?

`numbers.length` — returns the number of elements in the array.

79
New cards

What does this code output: `int[] nums = {5, 10, 15}; println(nums[1]);`?

10 — index 1 is the second element.

80
New cards

What's wrong with this code: `int[] arr = new int[3]; arr[3] = 99;`?

Array index out of bounds. Valid indexes are 0, 1, 2. Index 3 doesn't exist.

81
New cards

How do you loop through every element in an array?

`for (int i = 0; i < arr.length; i++) { println(arr[i]); }`.

82
New cards

Can you store Strings in an array?

Yes. `String[] names = {"Ali", "Sai", "Maya"};`.

83
New cards

What happens if you try to access an index outside the array?

You get an ArrayIndexOutOfBoundsException — a runtime error.

84
New cards

What's wrong with this code: `int[] scores = new int[5]; println(scores.length());`?

`length` is a property, not a method. No parentheses — should be `scores.length`.

85
New cards

Is `boolean` a primitive data type?

Yes — A) Yes ✓ B) No C) Only in Processing D) It depends.

86
New cards

Is `String` a primitive data type?

No — A) Yes B) No ✓ C) Sometimes D) Only if it's one character.

87
New cards

Which of these is a boolean expression? `A) x = 5 B) x == 5 C) x + 5 D) String x`

B) x == 5 ✓.

88
New cards

What does `&&` mean?

A) OR B) NOT C) AND ✓ D) Equal to.

89
New cards

What does `||` mean?

A) AND B) NOT C) Equal to D) OR ✓.

90
New cards

while loop

Which loop always runs at least once?

91
New cards

What index is the first element of an array?

A) 1 B) 0 ✓ C) -1 D) Depends on the array.

92
New cards

What does draw() do in Processing?

A) Runs once at start B) Draws a shape C) Loops continuously ✓ D) Sets the window size.

93
New cards

What does setup() do in Processing?

A) Runs once at the start ✓ B) Loops forever C) Draws a rectangle D) Declares variables.

94
New cards

What's the correct way to compare two values in Java?

A) = B) == ✓ C) === D) equals.