*
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 36478
    
  16
Please tell us where that question comes from.
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9280
    
  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: 36478
    
  16
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
 
Similar Threads
Khalid's Q6b0c
Question from mock exam
Legal Data Types
Questions from Dan and Green's Exams..
method arguments ?