• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 201
1
Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
It's a pleasure to see superheros taking such an interest in science. And this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic