aspose file tools*
The moose likes Beginning Java and the fly likes Mock Exam Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Mock Exam Question" Watch "Mock Exam Question" New topic
Author

Mock Exam Question

Rob Poulos
Ranch Hand

Joined: Aug 21, 2009
Posts: 49
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)






SCJA, ITIL V3 Foudation, Studying for SCJP6
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40051
    
  28
Please tell us where that question comes from.
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9321
    
  17

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


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40051
    
  28
Thank you for adding the link about where the question was from.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Mock Exam Question