• 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

stream

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
This question is from java caps:
13. Low Level Streams read input as bytes and writes as bytes, then select the correct declarations of Streams.
[a] FileInputStream FIS = new FileInputStream("test.txt")
[b] File file = new File("test.txt"); FileInputStream FIS = new FileInputStream(file)
[c] File file = new File("c:\\"); File file1 = new File(file,"test.txt"); FileOutStream FOS = new FileOutputStream(file1);
[d] FileInputStream FIS = new FileInputStream("c:\\","test.txt")
The answer is a,b,c,d but I think that is only a,b. In case c, what means FileOutStream??? and case d, I believe that FileInputStream don�t have a constructor FileInputStream(String, String)
Thank you ind advance.
 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Answers a, b and c are correct. d is incorrect becuase there is no contructor in FileInputStream like this.
c is correct, its dealing with FileOutputStream which can be used to write data to the file pointed to by file1 object.
Hope this helps.
------------------
Asma Zafar,
Sun Certified Programmer for Java2 Platform
 
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI,
I agree with Jordi.
I looked in the documentation and there is no string , string arguments in any specified constructor.
I put it in a code that worked before and the compiler started complaining about the double string.
Well spotted Jordi ! (�bien hecho!)
Terry Doyle
 
Ranch Hand
Posts: 1157
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
The answers should be A and B.It can be also C, if FileOutStream is infact FileOutputStream.D is incorrect since the constructor of FileInputStream takes the wrong number of parameters.
Hope this helps,
Sandeep
SCJP2, OCSD(Oracle JDeveloper), OCED(Oracle Internet Platform)
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic