• 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

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

 
Ranch Hand
Posts: 352
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
     
    Ranch Hand
    Posts: 46
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • 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
      Number of slices to send:
      Optional 'thank-you' note:
    • 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
     
    With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    reply
      Bookmark Topic Watch Topic
    • New Topic