wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes ExamLab Question - Formatting Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
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
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 2888
    
  13

Well, try this out:


Can you see the difference?

Author of ExamLab ExamLab - a free SCJP / OCPJP exam simulator
My 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
Sheriff

Joined: Aug 03, 2008
Posts: 9280
    
  17

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
 
Consider Paul's rocket mass heater.
 
subject: ExamLab Question - Formatting
 
Similar Threads
A possible wrong answer in ExamLab?
GC problem
Formatter class problem
using switch case?
ExamLab for SCJP 6.0 is now released