This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes  ID:7     SCJP Question of the day  !!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark " ID:7     SCJP Question of the day  !!! " Watch " ID:7     SCJP Question of the day  !!! " New topic
Author

ID:7 SCJP Question of the day !!!

Sahil Kapoor
Ranch Hand

Joined: Sep 12, 2009
Posts: 316
Consider the following program and tell the Output ???



Thanks !!!
Looking for other pals to continue this theme or series of questions !!!



Link to rules: http://www.coderanch.com/t/498524/java-programmer-SCJP/certification/ID-SCJP-day-Wednesday-June

[HENRY: Added link to rules]


SCJP 6.0 96%

(Connecting the Dots ....)
Mohit G Gupta
Ranch Hand

Joined: May 18, 2010
Posts: 634

Found Float 14.4 //Found Double 14.4
Found Short 1
Found Short 2
Found Short 3
Found Short 4
Found Short 127
Found Short 128
Found Short 32767
Found Integer 32768
Waste 12L // Found Long 12L
Waste 13.2f // Found Float 13.2f
Found Float 14.3
Found Short 143


i tried it myself and then run it using jcreator
there are 3 places where i went wrong(marked as comments)
can anbody explain why
the first line of output is
Found Float 14.4
as
Float as=14.4; gives compiler error
and
similarly,
long can be assigned 12L and float can be asssigned 13.2f so, why waste is in the output


OCPJP 6.0 93%
OCPJWCD 5.0 98%
Martin Vanyavchich
Ranch Hand

Joined: Sep 16, 2008
Posts: 241
Found float 14.4
Found Short 1
Found Short 2
Found Short 3
Found Short 4
Found Short 127
Found Short 128
Found Short 32767
Found Integer 32768
Found Long 12
Found Float 13.2
Found Float 14.3
Found Short 143
123
[some negative value]


... I think ;)


SCJP 6, OCMJD 6, OCPJWSD 6
I no good English.
Martin Vanyavchich
Ranch Hand

Joined: Sep 16, 2008
Posts: 241
After some testing I realized results are probably local dependant.



output is:


Where I come form ',' is considered as a decimal separator. A minor change in code gets what we're going for


output is:
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ID:7 SCJP Question of the day !!!