aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes InputStream question required Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "InputStream question required" Watch "InputStream question required" New topic
Author

InputStream question required

VINCE CARTER
Greenhorn

Joined: Sep 26, 2004
Posts: 13
1:
Which two create an InputStream and open file the �file.txt� for reading? (Choose Two)
A. InputStream in=new FileReader(�file.txt�);
B. InputStream in=new FileInputStream(�file.txt�);
C. InputStream in=new InputStreamFileReader (�file.txt�, �read�);
D. FileInputStream in=new FileReader(new File(�file.txt�));
E. FileInputStream in=new FileInputStream(new File(�file.txt�));
Answer: B, E
2:
Which two construct an OutputSream that appends to the file �file.txt�? (Choose Two)
A. OutputStream out=new FileOutputStream(�file.txt�);
B. OutputStream out=new FileOutputStream(�file.txt�, �append�);
C. FileOutputStream out=new FileOutputStream(�file.txt�, true);
D. FileOutputStream out=new FileOutputStream(new file(�file.txt�));
E. OutputStream out=new FileOutputStream(new File(�file.txt�)true);
Answer: C, E

Does the answers are right ?
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Insert the missing comma in 2.E, and I think you got it.


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
VINCE CARTER
Greenhorn

Joined: Sep 26, 2004
Posts: 13
What ??
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
I think you will find the answer by reading theAPI for FileOutputStream.
[ September 27, 2004: Message edited by: Barry Gaunt ]

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
I think Dirk means change:
OutputStream out = new FileOutputStream(new File(�file.txt�)true);

to

OutputStream out = new FileOutputStream(new File(�file.txt�), true);

in Question 2, E and this SCJP 1.2 answer will be correct.
PETER CARTER
Ranch Hand

Joined: Aug 28, 2004
Posts: 70
But I mean :
If we choice B and E for 1,we should choice A and D for 2.
But it's wrong ,why ??
Thanks !!!
Help me in your heart !!
Ramesh Kale
Greenhorn

Joined: Jun 21, 2004
Posts: 13
Hi all,
Sorry for posting the thread.
I read that all objectives of scjp1.4 there is no any object realted with java.io.

I am right? on above statement.
Please corrent me if i am going wrong.


Regards<br />Ramesh<br />(SCJP 83%)<br />Failure is part of success!!!
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
That's right. IO is not in SCJP 1.4.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: InputStream question required