This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Short Pop Quiz

 
Mike Cunningham
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The file in the example below was 5 bytes long. What is the length of the file after the following code gets executed?

The answer is supposed to be 6 but I don't see how it computes this answer?
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First the content of the file is overwritten and not appended.
Then, "BYE" is composed of three characters and a character is 2-bytes long => 3*2 = 6 bytes !
HIH
------------------
Valentin Crettaz
Sun Certified Programmer for Java 2 Platform
 
Mike Cunningham
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the info. You're GOOD!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic