This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

inner class

 
jaman tai
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which of the following statements is true?

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

b) An interface can contain a member inner class.

c) A member inner class can implement an interface.

d) A static method can contain a local class.

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

are the answers c and d? why a is not correct?
[ October 18, 2005: Message edited by: Barry Gaunt ]
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by jaman tai:
...why a is not correct?

Ask yourself: What does "nested top-level inner" mean? :roll:
[ October 18, 2005: Message edited by: marc weber ]
 
Fes D Gaur
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which of the following statements is true?

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

b) An interface can contain a member inner class.

c) A member inner class can implement an interface.

d) A static method can contain a local class.

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


I think b,c, and d are correct:

public interface TopInterface{
public class InnerClass{
InnerClass(){
System.out.println("Hi");
}
public static void main(String r[]){
InnerClass in = new InnerClass();
}
}

}

Also

public class StaticInner{
public static void StaticMethod(){
class LocalClass{

}
}
}

Please let me know if this is wrong.

Thanks,
Fes
 
jaman tai
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
interface A{
class B{} //this is static!
}

because B is static, i think it is top-level inner class. if i am wrong, please correct me.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic