This week's book giveaway is in the JavaFX forum.
We're giving away four copies of Introducing JavaFX 8 Programming and have Herbert Schildt on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Short Pop Quiz Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Introducing JavaFX 8 Programming this week in the JavaFX forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Short Pop Quiz" Watch "Short Pop Quiz" New topic

Short Pop Quiz

Mike Cunningham
Ranch Hand

Joined: Nov 14, 2000
Posts: 130
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

Joined: Aug 26, 2001
Posts: 7610
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 !
Valentin Crettaz
Sun Certified Programmer for Java 2 Platform

[Blog] [Blogroll] [My Reviews] My Linked In
Mike Cunningham
Ranch Hand

Joined: Nov 14, 2000
Posts: 130
Thanks for the info. You're GOOD!
I agree. Here's the link:
subject: Short Pop Quiz
It's not a secret anymore!