[Multiple Choice]Valid data type

  • Thread starter Thread starter jackylaucf
  • Start date Start date
  • Tags Tags
    Data Type
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
4 replies · 2K views
jackylaucf
Messages
3
Reaction score
0
hey guys I am learning greenfoot programming in college. I found out one multiple choice question that make me quite confused.

Which of the following is a valid data type?
A. integer
B. floating
C. boolean
D. number

Why is the answer option C?
I think that integer, floating and boolean are all valid data type...

Would someone like to explain it please? Thank you!
 
Physics news on Phys.org
I guess that the question is related to a specific programming language and you are supposed to answer which of the four is a valid data type in that language. For instance, for Java, answer C would be correct as the three others are not valid native data types in Java.
 
Your question puzzled me at first because I had never heard of a programming language named "Greenfoot." A bit of searching revealed that Greenfoot is actually a programming environment (set of tools and user interface) for the Java language. Don't confuse the language with the tools that you use to write programs in it. There are many ways (sets of tools) that you can write Java programs.

Anyway, Java does have a floating data type, but it's called "float", not "floating". Actually it has two of them: "float" and "double". They can store data with different precision (number of digits). Similarly, Java doesn't have a type called "integer". There are four integer types, which I'll let you look up for yourself.
 
jtbell said:
A bit of searching revealed that Greenfoot is actually a programming environment

Aha! When I read that post I thought "greenfoot" was some kind of slang for beginner .. which I guess it is in some way. At least, Greenfoot do look like a nice environment for beginners to learn programming. Making actors move and interact on screen seems so much more interesting and relevant than the usual type of assignments beginners get when learning Java.