NEW
Font size
WorksheetsJava-I-ch02_quiz01
Total questions: 10
Worksheet time: 5mins
What is a variable in Java?
A) A storage location in memory
B) A data type in Java
C) A method that performs calculations
D) A reserved word in Java
Which of the following is a correct declaration of a variable in Java?
A) int num = 100;
B) 100 = int num;
C) num int = 100;
D) int 100 = num;
What is the result of the following code?
10
20
30
40
Which operator is used to find the remainder after division in Java?
/
#
%
++
3
5
8
15
Which data type should be used to store a number with a decimal in Java?
int
double
char
boolean
What does the following code print?
3
3.3333
3.0
Error
What is the result of the expression 10 % 3 in Java?
0
1
2
3
What is the purpose of the ++ operator in Java?
A) To add two variables
B) To multiply a variable by 2
C) To increment a variable by 1
D) To perform a division operation
Which of the following correctly initializes a variable num with the value 5 in Java?
A) int num = 5;
B) int num = "5";
C) int num == 5;
D) int num = '5';
