• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

try these questions about I/O and threads?

 
Luyan Sun
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • 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!
 
mark stone
Ranch Hand
Posts: 417
  • Mark post as helpful
  • send pies
  • 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 ]
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • 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
  • 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?

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic