Meaningless Drivel is fun!
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes FilterOutputStream 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 "FilterOutputStream" Watch "FilterOutputStream" New topic


Ranch Hand

Joined: Sep 14, 2000
Posts: 43
what are the possible parameters that can be passed into the construcor of a
a.File b.PrintStream c.FileOutputStream d.FileInputStream e.RandomAccessFile

can anybody ans to this Question:
my ans is a:File & b:PrintStream
please help
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
FilterInputStream(InputStream in) - This is the only constructor available for this class.
Therefore all those params that can be converted to
InputStream in would be valid.
In your case:
File - It extends Object. So u can't use this.
PrintStream - not a subclass of InputStream, but a subclass of OutputStream. The hierarchy is :
outputStream -> FilterOutputStream->
Therefore, we can't use this as well.
FileInputStream - Subclass of InputStream. so, this is OK.
RandomAccessFile - NO ! Coz it does fall under any of the InputStream hierarchy.
Therefore my ans would just be FileInputStream .
Please let me if there is something wrong with this reasoning.

Joined: Jun 27, 2001
Posts: 15
Hi sampaths77,
have u tried by passing the FileInputStream into FilterInputStream constructor???becz it is saying that there is no constructor matching for FilterInputStream.and moreover FilterInputStream and FileInputStream belongs to the same level of that case u can not pass one stream into another.
only the ans could be InputStream.
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
please try this:
class B extends
B() throws Exception
super (new FileInputStream("yahoo"));
public static void main(String[] args)

I am able to compile this piece of code fine.
PLease note that questio just asked:what are the POSSIBLE parameters that can be passed into the construcor of a
FilterInputStream. Since i can do with the above code, I opted for FileInputStream
Plus you say that FileInputStream and FilterInputStream are in the siblings, but this has got nothing to do with the answer coz if u look at the constructor, the i/p param is InputStream. So, the code should compile for all subclasses of imputstream.
Hope this helps
I agree. Here's the link:
subject: FilterOutputStream
It's not a secret anymore!