Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

simple print statement

 
Kailash Bisht
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Given:

Which code fragment, inserted at line 4, produces the output | 12.345|?
A. System.out.printf("|%7d| \n", d);
B. System.out.printf("|%7f| \n", d);
C. System.out.printf("|%3.7d| \n", d);
D. System.out.printf("|%3.7f| \n", d);
E. System.out.printf("|%7.3d| \n", d);
F. System.out.printf("|%7.3f| \n", d);


can anyone explain me how does this code works..??
 
Anayonkar Shivalkar
Bartender
Posts: 1557
5
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Kailash Bisht,

Welcome to CodeRanch!

Plese, UseCodeTags. As of now, I've edited your post and added code tags. It makes much easier for others to read the code.

Secondly, please SearchFirst. Did you tried by inserting all those given lines? Did you see what kind of outputs are produced by those?

Once you've done that, and if you still have doubt(s) about any specific option, please feel free to ask.

I hope this helps.
 
Campbell Ritchie
Sheriff
Pie
Posts: 50206
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And you should always tell us where such questions come from. I presume you know all about the % tags: if not, start here and use ctrl‑F‑formatting to find the appropriate sections (I think there are two).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic