Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question on why this is an incorrect answer - From Gupta OCA book CH2 - Java data types

 
Ted North
Ranch Hand
Posts: 201
1
Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The question asks
Which of the following options contain correct code to declare and initialize variables to store whole numbers?


I got all the answers right but I had an extra answer that would make my response incorrect according to this test.

Apparently
double a5 = 0;
is incorrect. Although, this obviously will compile and run.

Are there tricky questions on the actual OCA exam like this? Where the code will compile and run but the question is looking for something very specific such as which data-types are designed specifically to store integers?

public void main String array,

Ted
 
Roel De Nijs
Sheriff
Posts: 10392
133
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's not a trick question! All words in the question matter. Question clearly states it should be a whole number. Although double a5 = 0; compiles and runs, it isn't correct because double is used to represent decimals (not whole numbers).
 
Ted North
Ranch Hand
Posts: 201
1
Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Roel De Nijs wrote:That's not a trick question! All words in the question matter. Question clearly states it should be a whole number. Although double a5 = 0; compiles and runs, it isn't correct because double is used to represent decimals (not whole numbers).


Roger. Thank-you kind sir for the helpful reply. I should of read this more carefully.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic