Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization 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