aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Input/Output(urgent) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Input/Output(urgent)" Watch "Input/Output(urgent)" New topic
Author

Input/Output(urgent)

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
1. Reading one line of data at a time from a socket connected to the network
with an input stream object s. The output to be in standard ASCII character
encoding.
(a)DataInputStream da = DataInputStream(s.getInputStream());
(b)DataInputStream do = DataInputStream(FileInputStream(g.getInputStream());
(c)BufferedReader b= new BufferedReader
(newInputStreamReader(s.getInputStreamReader));
(d)BufferedReader b= new BufferedReader
(newInputStreamReader(s.getInputStreamReader), "8859_1");
2. what is the correct format of reading a line of
String objects ?
a) FileInputStream fis = new
FileInputStream("Filename.txt");
b) DataInputStream dis = new DataInputStream(new
FileInputSTream("FileName.txt"));
c) DataInputStream dis = new DataInputStream(new
FileInputSTream("FileName.txt"), "r");
Can anyone help me.
kishore kota
Greenhorn

Joined: Sep 23, 2000
Posts: 5
hai peter ,
for the 1st queswtion as per my knowledge the ans should contain the ASCII code as the last argument in the constructer so the ans
may be 'd'
hope this will help u,
if wrong correct me
tnks,
krishna
Kishan Kumar
Ranch Hand

Joined: Sep 26, 2000
Posts: 130
1.
b is the correct answer.
d would have been correct if the arguments were passed correct.
BufferedReader b= new BufferedReader
(newInputStreamReader(s.getInputStreamReader), "8859_1");
the "8859_1" String parameter should be in the constructor of
InputStreamReader.
2. b is the correct answer
This question is asked by Janani, and eplanation is given for
this in that post.
All,
I am a buddy to this group and can I know what "green horn"
means.
Thanks


Regards,<BR>V. Kishan Kumar
scott irwin
Ranch Hand

Joined: Aug 07, 2000
Posts: 87
1) A is correct. Because the stream is said to be standard ASCII encoding we don't need a Reader(?). Only A has a valid constructor. In B, FileInputStream doesn't take an InputStream, only String, File and FileDescriptor.
2) If the FileInputSTream is a typo (FileInputStream) then B is correct, otherwise none.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Input/Output(urgent)
 
Similar Threads
InputStreams
I/O
I / O
input/output
Error printing out from a read in file.