File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes ExamLab Question - Formatting Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "ExamLab Question - Formatting" Watch "ExamLab Question - Formatting" New topic
Author

ExamLab Question - Formatting

Richa Sharma
Ranch Hand

Joined: Dec 06, 2008
Posts: 47
Hi Guys

why does the output includes true in this examlab question?



Thanks
Richa
Devaka Cooray
Saloon Keeper

Joined: Jul 29, 2008
Posts: 2691
    
    3

Well, try this out:


Can you see the difference?

Author of ExamLab (Download) - the free mock exam kit for SCJP / OCPJP
Home Page -- Twitter Profile -- JavaRanch FAQ -- How to Ask a Question
Richa Sharma
Ranch Hand

Joined: Dec 06, 2008
Posts: 47
Got It Thanks Deveka
S Ali
Ranch Hand

Joined: Aug 23, 2009
Posts: 129
because %b will print true for any non boolean type that is not null.


SCJP 6
Fritz Guerilus
Ranch Hand

Joined: Jun 20, 2009
Posts: 65
I thought the answer would be:
07.00settrue
based:
on the flag being 0
and
the width being 2

But I compiled/executed the code and the answer is:
7.00settrue.

My question:
what happened to the flag & width ("%02...") portion of the format specifier?

-Thank You


SCJP 6.0
Ankit Garg
Saloon Keeper

Joined: Aug 03, 2008
Posts: 9189
    
    2

The %02. portion includes the width of the fractional part too, so it says that the minimum width of the number should be 2 including the part after the decimal point...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ExamLab Question - Formatting
 
Similar Threads
using switch case?
Formatter class problem
ExamLab for SCJP 6.0 is now released
A possible wrong answer in ExamLab?
GC problem