• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

InputStream question required

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ?
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Insert the missing comma in 2.E, and I think you got it.
 
VINCE CARTER
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What ??
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you will find the answer by reading theAPI for FileOutputStream.
[ September 27, 2004: Message edited by: Barry Gaunt ]
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 !!
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's right. IO is not in SCJP 1.4.
 
reply
    Bookmark Topic Watch Topic
  • New Topic