Data Types Practice#
These questions are to assess your understanding of the different Java data types and how they should be used.
Questions 1
Imagine you are writing a program that stores a high school or college student’s class year, which can take the values of Freshman, Sophomore, Junior, or Senior. Which of the folloing is an appropriate data type for this information?
Integer
Double
String
See Answer
String is an appropriate data type for this information!
The student’s year is a piece of text, either Freshman, Sophomore, Junior, or Senior.
Question 2
Imagine you are writing a program that stores the number of gel pens you have. What is an appropriate data type for this information?
Integer
Double
String
See Answer
Integer is an appropriate data type for this information!
The number of gel pens you have will be a whole number, so an integer is appropriate.