NEW
Font size
WorksheetsAP CSA Variables and Operators
Total questions: 14
Worksheet time: 7mins
Which variable type is NOT a primitive variable type?
boolean
String
int
double
What is a logic error?
An mistyped statement that causes the compiler to throw an exception.
An illegal operation that causes the compiler to throw an exception.
An illegal operation that causes the program to have a run-time error.
An error a programmer makes that causes the program to behave differently than expected.
What is the correct syntax to instantiate a Finch object with its default constructor?
Finch(f);
Finch f;
Finch f = Finch();
Finch f = new Finch();
What is the result of 3/2 in Java?
1.5
1.0
1
0
What is the result of 3.0/2 in Java?
1.5
1.0
1
0
What is the % operator in Java?
percentage
homonculus
modulus
modulator
What is the result of 3%2?
1
1.5
1.0
0
What is the result of 2%1?
0
1
2
This cannot be calculated.
What is the difference between primitive variables and Object reference variables?
Primitive variables hold a variable's value, whereas Object reference variables do not a value, they point to it .
Primitive variables take up a specific amount of memory, whereas the amount of memory an Object reference can take up varies.
Both answers are correct.
What is the long form of x++?
x += x;
x = x + 1;
x + 1;
y = x + 1;
What is the long form of x--?
z = x - y;
x - 1;
x -= x;
x = x - 1;
What is the long form of x+=5?
x = 5;
x = + 5;
x = x + 5;
y = x + 5;
Where does modulus fall within the PEMDAS order of operations?
After multiplication and division
Before multiplication and division
At the same level of multiplication and division
Whenever you feel like it.
Which statement is an incorrect attempt at instantiating a String object?
new String("hi!");
String s = new String("hi!");
String s = "hi!";
String s = String("hi!");
