This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Mock Exam Question

 
Rob Poulos
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://www.scja.de/scja-mock-exam-section3.html

The Question:



My answer was A,B,C,D as i figured that 'float f=3.5' would still compile but f would be converted to a double as 3.5 was not casted with a F (3.5F)





 
Campbell Ritchie
Sheriff
Pie
Posts: 48972
60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please tell us where that question comes from.
 
Ankit Garg
Sheriff
Posts: 9521
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
f would be converted to a double as 3.5 was not casted with a F (3.5F)


You caught it right that 3.5 without the F is a double value, but how can the datatype of f be converted. We cannot change the type of a variable once it is declared. So that line will not compile as we are trying to assign a double value to a float variable....
 
Campbell Ritchie
Sheriff
Pie
Posts: 48972
60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for adding the link about where the question was from.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic