This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes try these questions about I/O and threads? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "try these questions about I/O and threads?" Watch "try these questions about I/O and threads?" New topic
Author

try these questions about I/O and threads?

Luyan Sun
Greenhorn

Joined: Feb 08, 2002
Posts: 4
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

Joined: Dec 18, 2001
Posts: 417
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

Joined: Aug 26, 2001
Posts: 7610
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 ]

SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
Luyan Sun
Greenhorn

Joined: Feb 08, 2002
Posts: 4
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?

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: try these questions about I/O and threads?
 
Similar Threads
Regarding reading a file in a jsp
Marcus Q# 53 I/O
IO Questions
Files I/O
input/output