Font size
WorksheetsAP Computer Science A Post Unit 2 Check
Total questions: 18
Worksheet time: 9mins
If x = 3 and y = 5, choose all the statements that evaluate to True.
x < y
y > -x**2
2 * x == y
y % x == 3
A Boolean expression...
Fixes any errors in the line of code
Sets everything in it equal to each other
Checks if something is true or false
Loops the program to continue infinitely
How many values does a Boolean variable have?
4
3
2
1
Infinite
a = 5
b = 6
Determine the truth value of the following statement:
((a <= b) or (a == b)) and (b > a)
True
False
Which Java type can be used to store a true or false value?
boolean
bool
Boolean
Bool
14 >= 14
15 > 15
16 != 16
18 >= 19
True/False: The body of an "if" statement will only be executed if the condition is true.
True
False
What is the value of num after this statement is executed?
int num = 23;
if(num>20) { num = 20; }
else { num = 30; }
20
30
23
true
What is missing from the command: System.___.println("Hello World");
prt()
Sys
java
out
How many classes are required in a Java Program?
At least one.
None, you can run a basic program without a class.
Two, one for the main function and one for the function code.
None of the above.
Which is the correct way to end a command statement in Java?
;
,
.
:
Which of the reserved words is missing in this line which is found in every Java program?
public _____ void main(String[] args) {
private
void
open
static
Which reserved word allows other classes to access your class in Java?
private
call
public
open
Which of these is NOT a primitive datatype in Java?
float
int
String
char
If you wanted to store the value 2.5 in a variable what datatype would you need to use?
char
float
int
boolean
What will the output be?
Nothing, there is an error
OrangeBlack
Orange
Black
Which boolean operator should replace the @ in this code?
=
<=
==
equal
What is the value of bool after running this code?
true
undefined
false
5 + 7
