Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

khalid mughal

 
shabbir zakir
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • 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.
 
nitin sharma
Ranch Hand
Posts: 290
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic