• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

IBM Mock exam question,

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which of the following statements is true?





a) An interface can contain a member inner class.

b) A member inner class can implement an interface.

c) An interface can contain a nested top-level inner class.

d) A static method can contain a nested top-level class.

---------------------------------
I tried to coding the above answeres and statements a,b,c are true !? am I right?
thanx
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
could u please explain how a b and c are correct and why d is not.
i am totally confused of inner classes
thanx
 
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am giving an example code here. Try to analyze further.
<pre>
interface Inter {
class InnerClass {
}
static class NestedTopLevelInnerClass {
}
interface InnerInter {
}
static interface NestedInter {
}
}
class Test {
void m1() {
Inter.NestedTopLevelInnerClass c1 = new Inter.NestedTopLevelInnerClass();
}
}
</pre>
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I understand why a,b,c are right. But can anyone explain why d is wrong? static method can't have static class inside it?
Thanx
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think I got the answer. Static block can't be included in a method.
 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure a is right. Although it will compile it is not a "member" class. Inner Classes of an interface are inherently static ( top-level ).
 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am unable to run IBM exam from my m/c. Whenever I login it gives some class not found exception. Can u provide the exact
URL plus browser name/version u all are using
 
Praveen Kumar
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am unable to run IBM exam from my m/c. Whenever I login it gives erro (Fatal Error - a session could not be found or created) Can u provide the exact
URL plus browser name/version u all are using
------------------
Praveen Kumar
Mumbai ,India
email: bades@vsnl.com
 
I love a good mentalist. And so does this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic