Grade 10/11 IT Classwork: Java Data Types
Topic: Primitive Data Types
Name: _______________________ Date: _______________________
Part A: Theory Questions
1. What is a data type? (2 marks)
Answer:
_______________________________________________________
_______________________________________________________
2. List any FOUR primitive data types in Java and give an example of each. (8 marks)
Data Type Example Declaration
3. What is the difference between int and double? (2 marks)
Answer:
_______________________________________________________
_______________________________________________________
4. Why must characters be stored using single quotes ' in Java? (1 mark)
Answer:
_______________________________________________________
Part B: Code-based Questions
5. Look at the following code and answer the questions below:
int age = 16;
double height = 1.72;
Page 1
Grade 10/11 IT Classwork: Java Data Types
char gender = 'F';
boolean isStudent = true;
a. What is the value stored in the variable height? (1 mark)
Answer: ___________________________
b. Which variable holds a true/false value? (1 mark)
Answer: ___________________________
c. What will be displayed if we add this line?
[Link](gender);
(1 mark)
Answer: ___________________________
Part C: Write Your Own Code
6. Write Java code that declares and stores the following:
- Your shoe size as a float
- Your favourite letter as a char
- Whether you have a pet as a boolean
(3 marks)
// Your answer here:
Total: 20 marks
Page 2