Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

class inside interface

 
kanchan chaudhary
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which of the following are true about the class defined inside an interface
1. it is not possible in the java Laungage.
2. The class is always public.
3. The class is always static.
4. the class methods cannot call the methods declared in the interface.
5. the class methods can call only the static methods declared in the interface
Thanks
kanchan
 
Angela Lamb
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. False - it is possible. See JLS section 9.1.3.
2. True - according to JLS, "all interface members are implicitly public."
3. True
4. True - since the class is static, it can't make calls to non-static methods.
5. False - static methods may not be declared in an interface.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic