Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

In need of clarification of wording in an SCJA Mock question.

 
Stephen Davies
Ranch Hand
Posts: 352
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Going through a quick-fire test in a SCJA exam engine, I came across this statement:

This codecompiles without errors?



  • True -Exam answer:
  • False


  • -Exam description-The given code compiles correctly ,because it is a widening conversion from long to float and hence is allowed.



    Is it it not trying to convert float to long, are we not taking a float reference (f)and trying to assign it a long value,or am i mistaken, and its just a little badly worded?

    It does complile however!


    [ September 23, 2008: Message edited by: Stephen Davies ]
     
    patrick avery
    Ranch Hand
    Posts: 46
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    "Is it it not trying to convert float to long, are we not taking a float reference (f)and trying to assign it a long value,or am i mistaken, and its just a little badly worded? "

    My understanding is that the type of a reference cannot ever change, once declared, so in this case f is and will always be a float and contain only float values, so 12L MUST be converted to a float in order to get stuffed into f.

    So it seems, to me, that the Mock Test's verbiage of "widening conversion from long to float" is accurate.

    Thanks, Pat
     
    Stephen Davies
    Ranch Hand
    Posts: 352
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Pat,

    Thanks, that eases things, yes your right, but I still think they could have worded it a little better in their description!

    Steve
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic