• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is this a valid Interface declaration?

 
Jasper Vader
Ranch Hand
Posts: 284
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
interface Worker {
void perform_work();
}
... i found the above code in a mock exam... i thought that all methods in an interface need to be abstract?
 
Sridhar Srikanthan
Ranch Hand
Posts: 366
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jasper,
all the methods in an interface are implicitly public and abstract. It doesnt matter even if you explicitly state them
Similarly, all variables in interfaces are implicitly public, static and final.
You might have got confused with abstract classes in which the declaration of abstract methods is explicitly done with the abstract keyword
Hope this Helps
Sri
 
Jasper Vader
Ranch Hand
Posts: 284
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
cheers Sri, thanks for the clarification!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic