• 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

try these questions about I/O and threads?

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,everyone!
I meet some truble when I studying I/O and threads.I'm very appreciate if you can give me some good advice.
1)A file stored on local disk is to be read one line at a time into String
objects,which constructions would be the mst suitable for reading the file?
A.FileInputStream in=new FileInputStream("file.name");
B.DataInputStream in=new DataInputStream(new FileInputStream("file.name"));
C.DataInputStream in=new DataInputStream(new FileInputStream("file.name","r"));
D.BufferedReader in=new BufferedReader(new FileInputStreamReader(new FileInputStream("file.name")));
E.BufferedReader in=new BufferedReader(new InputStreamReader(new FileInputStream("file.name"),"8859_1"))
2)which statemens about threads are true?
A.Uncoordinated changes to shared data by multiple threads may result in the data being read,or left,
in an inconsistent state.
B.The Java interpreter's natural exit occurs when no non-daemon threads remain alive ;
C.Threads created from the same class all finish together.
3)FilterInputStream is the parent class for BufferedInputStream,DataInputStream
and LineNumberInputStream.Which classes,individually,are valid as an argument
for the constructor of FilterInputStream?
A.FileInputStream
B.FileOutputStream
c.File
D.RandomAccessFile
E.PrintStream
thank you!
 
Ranch Hand
Posts: 417
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1 E.BufferedReader in=new BufferedReader(new InputStreamReader(new FileInputStream("file.name"),"8859_1"))
2 correcting it. A and B are true
3 A is ok
[ February 10, 2002: Message edited by: mark stone ]
[ February 10, 2002: Message edited by: mark stone ]
 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
2. A and B are true
C is badly worded, how do we know whether the "class" they are talking about is the class which contains the start() invocations or a Thread subclass ??
mark,
I have just a small request:
please quit "QUOTING" a whole message, it makes your post unnecessary long, populates the database for nothing and wastes bandwidth. Thank you
[ February 10, 2002: Message edited by: Valentin Crettaz ]
 
Luyan Sun
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Valentin Crettaz:
2. A and B are true
C is badly worded, how do we know whether the "class" they are talking about is the class which contains the start() invocations or a Thread subclass ??


Valentin, I'm not clear about your explaination, please give me more detailed explaination or example.
Mark,I think the third question you select A because FileInputStream and FilterInputStream are extends from InputStream and PrintStream and FileOutputStream are extends from OutputStream,am I right?

 
rubbery bacon. rubbery tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic