aspose file tools*
The moose likes Associate Certification (OCAJP 7/8) and the fly likes Question on why this is an incorrect answer - From Gupta OCA book CH2 - Java data types Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Associate Certification (OCAJP 7/8)
Bookmark "Question on why this is an incorrect answer - From Gupta OCA book CH2 - Java data types" Watch "Question on why this is an incorrect answer - From Gupta OCA book CH2 - Java data types" New topic
Author

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

Ted North
Ranch Hand

Joined: Jan 02, 2012
Posts: 193
    
    1

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
Bartender

Joined: Jul 19, 2004
Posts: 5528
    
  13

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).


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
Ted North
Ranch Hand

Joined: Jan 02, 2012
Posts: 193
    
    1

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question on why this is an incorrect answer - From Gupta OCA book CH2 - Java data types