aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes inner class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "inner class" Watch "inner class" New topic
Author

inner class

jaman tai
Ranch Hand

Joined: Sep 26, 2005
Posts: 37
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

Joined: Aug 31, 2004
Posts: 11343

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 ]

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Fes D Gaur
Ranch Hand

Joined: Apr 29, 2005
Posts: 54
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

Joined: Sep 26, 2005
Posts: 37
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: inner class