my dog learned polymorphism*
The moose likes I/O and Streams and the fly likes input/output Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "input/output" Watch "input/output" New topic
Author

input/output

sheri
Ranch Hand

Joined: Sep 14, 2000
Posts: 43

hi
1:Connected to a socket s, read one line of ASCII char. Please construct the right input method:
- InputStream in = new InputStream(s.getInputStream());
- DataInputStream in = new DataInputStream(s.getInputStream());
- BufferedReader in = new BufferedReader(InputStreamReader(s.getInputStream());
- BufferedReader in = new BufferedReader(InputStreamReader(s.getInputStream(), "8859_1");
Use socket method. "in" is an InputStream constructed by "InputStream in = new Socket().getInputStream();"
2: Which constructor is the most adequate for transmition of ASCII data from the socket?
- BufferedReader(InputStreamReader(in, "8859_1")) // his choice
- BufferedReader(InputStreamReader(in))
- DataInputStream(in)
- BufferedInputStream(DataInputStream(in))
- InputStreamReader(in)
3:You want to use the readLine() method which of the following will be the correct initialization?
a) BufferedReader bf = new BufferedReader(new InputStreamReader(new FileInputStream("file","8859_1")))
b) BufferedReader bf = new BufferedReader(new InputStreamReader(new FileInputStream("file")))
c) DataInputStream ds = new DataInputStream(new FileInputStream("file"))

4:What kind of Stream does DataInputStream accept?
what are the valid type of arguments for different types of streams & readers/writers...
can anybody ans these question.i am totally confused when i get these type of questions...
can anybody help with this..(any notes on this topic)so that i can read..& be ready for the exam..
thanx
sherinn
Mapraputa Is
Leverager of our synergies
Sheriff

Joined: Aug 26, 2000
Posts: 10065
here is one link: http://www.geocities.com/SiliconValley/Network/3693/java_cert.html


Uncontrolled vocabularies
"I try my best to make *all* my posts nice, even when I feel upset" -- Philippe Maquet
Ramesh Donnipadu
Ranch Hand

Joined: Sep 16, 2000
Posts: 100
Answer to Qn1.
-There is no readLine() method in InputStream.
-readLine() method is deprecated in DataInputStream.
-unbalanced parentheses and Argument to BufferedReader() is not correct.
-same as above.
The Correct answer I believe should be something like this.
BufferedReader in = new BufferedReader(new InputStreamReader(s.getInputStream()));
Or
BufferedReader in = new BufferedReader(new InputStreamReader(s.getInputStream()),"8859-1");
Ajith Kallambella
Sheriff

Joined: Mar 17, 2000
Posts: 5782
I am transferring this post to I/O and Streams forum
Ajith


Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: input/output