Help coderanch get a
new server
by contributing to the fundraiser
  • 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

khalid mughal

 
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
which of these statements concerning nested classes are true?
a) An instance of a top-level nested class has an inherent outer instance.
b)A top-level nested class can contain non-static member variables.
c)A top-level nested interface can contain non-static member variables.
d)A top-level nested interface has an inherent outer instance.
e) For each instance of the outer class,there can exist many instances of a non-static inner class.
The answers given are b & e. why cannot option c cannot be true.
For instance
class a
{
int i = 10;
static class v
{
static interface x {
void amethod();
int x = 10;
}

}
}
this code is compiling fine. Now i think that the option c is correct.
 
Ranch Hand
Posts: 290
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
c,is not the correct answer, reason being when u declare variable's inside an interface they r implicitly public, static , final.wheteher u specify static modifier in front of the variable's declaration or not it does not effect because variable's implicitly becomes static.
 
Do not meddle in the affairs of dragons - for you are crunchy and good with ketchup. Crunchy tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic