• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Q's

 
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
I have tried to answer the following Q's... please correct me if I am wrong.

1. Which of the following is true.
a. An interface can contain a top level nested inner class.
b. An interface can contain a member inner class. - T
c. A member inner class can implement an interface. - T
d. A static method can contain a local class.
e. A static method can contain a nested top level local class.

2. FilterInputStream chaining is defined as -
a. Ability to sequentially open a collection of streams.
b. Ability to redirect the output of one stream to the input of another - T
c. Ability to open a high level inputstream on a lower level input stream.
d. Ability to the constructor of one stream to call that of another.
In the above Q, all the options seems right..... but I think b is only true... Kindly help.
Thx in advance.
Aruna
 
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI,
for q.1
a is also right try the following code:
interface a{
public static class abc{}
}
the above code does not report an error. So (a) is right
For q-2 (d) is right as constructors do call other constructors while chaining.
Since it is not always chaining a hihg level stream to a low level stream (c) is false. BufferedInputStream can be chained with DataInputStream and both are high level streams.
(a) is false because only opening the streams does not gaurantee chaining. they have to be chained by constructor calls.
hope i am right and it helps u.

Sagar
 
Aru Ven
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thx for ur Help Sagar,
Aruna
 
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

The following code shows that static methods can have local inner classes defined within them. So option d is also correct.

//interface can contain a member inner class
//inner member class can implement an interface
interface II
{ public class CC
{ class DD implements II
{
}
int i;
static void amethod(){
class EE
{int e;
}
}
}
}
In my openion when we are chaining one input stream to another input stream one can always be considered a lower level.(The high and low levels are relative and not absolute)
Option B sounds more like describing Piped Input - Output, I dont know if that is correct. Any suggestions welcome.
 
There are 29 Knuts in one Sickle, and 17 Sickles make up a Galleon. 42 tiny ads in a knut:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic