Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) 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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!