1/93
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
What is a variable?
A named space in a computer's memory used to store a value.
What are the 7 primitive data types in Java/Processing?
int, double, long, short, byte, float, boolean, char
How many bits does int use? What range?
32 bits. Stores values from about -2.1 billion to 2.1 billion.
How many bits does long use?
64 bits
How many bits does short use?
16 bits
How many bits does byte use?
8 bits
What is double used for?
Decimal numbers, 64 bits
What is float used for?
Decimal numbers, 32 bits (less precise than double)
What is boolean?
1 bit — stores only true or false
What is char?
Single 16-bit character (one letter, symbol, etc.)
What are primitive data types?
The basic built-in types of a programming language.
What is a non-primitive data type?
Data types made up of multiple primitive values — more complex.
Is String a primitive data type?
No. String is non-primitive.
Is int a primitive data type?
Yes.
Is boolean a primitive data type?
Yes.
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;`.
What's wrong with this code: `String name = 'Sai';`?
Strings use double quotes, not single.
What's wrong with this code: `char letter = 'A';`?
char uses single quotes. Should be `char letter = 'A';`.
Which data type would you use to store someone's age?
int
Which data type would you use to store a price like $9.99?
double or float
Which data type would you use to store whether a light is on or off?
boolean
What does size(width, height) do in Processing?
Sets the size of the sketch window in pixels.
What does background(r, g, b) do?
Sets the background colour of the sketch using RGB values.
What does fill(r, g, b) do?
Sets the fill colour for shapes drawn after it.
What does stroke(r, g, b) do?
Sets the outline/border colour of shapes.
What does noFill() do?
Removes the fill so shapes are transparent inside.
What does noStroke() do?
Removes the outline from shapes.
What does ellipse(x, y, w, h) do?
Draws an ellipse.
What does rect(x, y, w, h) do?
Draws a rectangle.
What does line(x1, y1, x2, y2) do?
Draws a line from point (x1, y1) to point (x2, y2).
What does triangle(x1,y1,x2,y2,x3,y3) do?
Draws a triangle using three coordinate points.
What is setup() used for in Processing?
Runs once when the sketch starts.
What is draw() used for in Processing?
Loops continuously (like a game loop).
What does frameRate(n) do?
Sets how many times per second draw() runs.
What does mouseX and mouseY do?
Track the current position of the mouse.
What does println() do in Processing?
Prints a value to the console.
What's wrong with this code: `ellipse(50, 50, 30);`?
ellipse() needs 4 arguments, not 3.
What's wrong with this code: `void setup { size(500, 500); }`?
Missing parentheses after setup.
Top-left corner of the window.
In Processing, where does (0,0) start?
What is a boolean expression?
A statement that can only have two answers: true or false.
Give 3 examples of boolean expressions.
`5 > 3` (true), `10 == 7` (false), `score >= 750`.
What does == mean?
Checks if two values are equal.
What does != mean?
Not equal to.
What does && mean?
AND — both conditions must be true.
What does || mean?
OR — at least one condition must be true.
What does ! mean?
NOT — reverses/flips the boolean value.
What is an if statement?
The most basic conditional.
What is the structure of an if statement?
if (condition) { // code runs if true }
What does else if do?
Tests a second condition if the first if was false.
What does else do?
Runs if all previous conditions were false.
Yes
Is `5 > 3` a boolean expression?
Is `score = 100` a boolean expression?
No — that's assignment. A boolean expression would be `score == 100`.
What's wrong with this code: `if x > 5 { println("big"); }`?
Missing parentheses around the condition. Should be `if (x > 5)`.
What's wrong with this code: `if (x = 10) { println("ten"); }`?
Single `=` is assignment, not comparison. Should be `==`: `if (x == 10)`.
What does this evaluate to: `!(5 > 3)`?
false — because 5 > 3 is true, and NOT flips it to false.
What does this evaluate to: `(3 > 1) && (10 < 5)`?
false — because the second condition (10 < 5) is false, and both must be true for &&.
What does this evaluate to: `(3 > 1) || (10 < 5)`?
true — because the first condition is true, and || only needs one to be true.
What is a loop?
A block of code that repeats multiple times until a condition is no longer met.
What are the three types of loops in Java/Processing?
for loop, while loop, do-while loop.
What is the structure of a for loop?
`for (initialization; condition; update) { // code }`.
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).
What is a while loop?
Repeats as long as a condition is true. Checks the condition BEFORE running.
What is a do-while loop?
Runs the code FIRST, then checks the condition. Always executes at least once.
What does this loop print: `for (int i = 0; i < 5; i++) { println(i); }`?
0, 1, 2, 3, 4 (stops before 5).
What is an infinite loop?
A loop that never stops because the condition is always true. Usually a bug.
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++`.
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.
What does break do in a loop?
Immediately exits the loop.
What does continue do in a loop?
Skips the rest of the current iteration and goes to the next one.
How many times does this loop run: `for (int i = 1; i <= 10; i++) { }`?
10 times (i goes 1, 2, 3... 10).
How many times does this loop run: `for (int i = 0; i < 10; i++) { }`?
10 times (i goes 0, 1, 2... 9).
A collection of multiple values of the same data type stored together under one variable name.
What is an array?
Is an array a primitive or non-primitive data type?
Non-primitive.
How do you declare an array of 5 integers in Java/Processing?
`int[] numbers = new int[5];`.
How do you declare and fill an array at the same time?
`int[] numbers = {10, 20, 30, 40, 50};`.
How do you access the first element of an array?
`numbers[0]` — arrays are zero-indexed, so the first element is index 0.
How do you access the last element of an array with 5 elements?
`numbers[4]` — index goes 0, 1, 2, 3, 4.
What is the length property of an array?
`numbers.length` — returns the number of elements in the array.
What does this code output: `int[] nums = {5, 10, 15}; println(nums[1]);`?
10 — index 1 is the second element.
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.
How do you loop through every element in an array?
`for (int i = 0; i < arr.length; i++) { println(arr[i]); }`.
Can you store Strings in an array?
Yes. `String[] names = {"Ali", "Sai", "Maya"};`.
What happens if you try to access an index outside the array?
You get an ArrayIndexOutOfBoundsException — a runtime error.
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`.
Is `boolean` a primitive data type?
Yes — A) Yes ✓ B) No C) Only in Processing D) It depends.
Is `String` a primitive data type?
No — A) Yes B) No ✓ C) Sometimes D) Only if it's one character.
Which of these is a boolean expression? `A) x = 5 B) x == 5 C) x + 5 D) String x`
B) x == 5 ✓.
What does `&&` mean?
A) OR B) NOT C) AND ✓ D) Equal to.
What does `||` mean?
A) AND B) NOT C) Equal to D) OR ✓.
while loop
Which loop always runs at least once?
What index is the first element of an array?
A) 1 B) 0 ✓ C) -1 D) Depends on the array.
What does draw() do in Processing?
A) Runs once at start B) Draws a shape C) Loops continuously ✓ D) Sets the window size.
What does setup() do in Processing?
A) Runs once at the start ✓ B) Loops forever C) Draws a rectangle D) Declares variables.
What's the correct way to compare two values in Java?
A) = B) == ✓ C) === D) equals.