• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Urgent : how many bytes are output ??

 
Ranch Hand
Posts: 351
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello !
Suppose I output the String "test" .. how many bytes will be output to the stream ?
I thought 8.. the answer given was 4 !
Pls help.
 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Leena,
The reason is that, Java uses UNICODE for representing charachters internally, but uses UTF for IO.
UTF means UCS Transformation format
and UCS menas Universal charachter system.
UTF uses 1 or 2 or 3 bytes to represent charachter in IO
and all ASCII char's requires 1 byte only.
Thats why answer is 4 bytes.
Sujit

 
Leena Diwan
Ranch Hand
Posts: 351
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That was something !
I didn't take into consideration this use of UTF.
1)Is it true for the normal console output also ??
2)Is there any situation when 8 bytes will be output.
just to make sure.. otherwise I might get it wrong
in the exam !
Thank you very much Sujit.
It sure was a great help.
Leena
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic