Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Optional data types  RSS feed

 
B Sleek
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Would someone please explain the correct answer to this question?
4. Does every Java variable use a data type?
a. No---only numeric variables use data types.
b. No---data types are optional.
c. Yes---all variables are of the same data type.
d. Yes---each variable must be declared along with its data type.
The answer is b. Could someone give an example? Thank you!
 
Joe Ess
Bartender
Posts: 9428
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like a poor choice of words. Every variable declaration requires a type and a name. Perhaps the test author defines "data type" as referring to Java's "reference types", arrays and classes, and not the primitive data types like int.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!