It's not a secret anymore!
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
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "ExamLab Question - Formatting" Watch "ExamLab Question - Formatting" New topic

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?

Devaka Cooray
ExamLab Creator

Joined: Jul 29, 2008
Posts: 3915

Well, try this out:

Can you see the difference?

Author of ExamLab ExamLab - a free SCJP / OCPJP exam simulator
What would SCJP exam questions look like? -- Home -- Twitter -- 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.

Fritz Guerilus
Ranch Hand

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

But I compiled/executed the code and the answer is:

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

-Thank You

SCJP 6.0
Ankit Garg

Joined: Aug 03, 2008
Posts: 9462

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
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: ExamLab Question - Formatting
It's not a secret anymore!