• Post Reply Bookmark Topic Watch Topic
  • New Topic

can interface implement another interface?  RSS feed

 
Bhagyadhar Bishoi
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to get whether interface can be implemented by other interface.. i read about it but got a bit confused.. also i need to know its specific reason..
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

Think of it this way. The word "implement" (in Java context) would indicate that the implementing entity would provide a concrete implementation. According to Java rules interfaces cannot contain concrete implementations.

So what do you think? Can an interface implement another interface? How about extend?
 
Bhagyadhar Bishoi
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey thanks... i got it.. interface cant be implemented but extended by interfaces...
 
Mike Simmons
Ranch Hand
Posts: 3090
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oddly, however, it can be implemented by an abstract class with no implementation.
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maneesh Godbole wrote:According to Java rules interfaces cannot contain concrete implementations.

Except a static nested class.

Winston
 
Mike Simmons
Ranch Hand
Posts: 3090
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or except for field initializers, which can even use anonymous classes if you like. I have yet to see anyone actually use these for anything other than a proper constant, but they certainly allow other things there.
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mike Simmons wrote:Oddly, however, it can be implemented by an abstract class with no implementation.


Why is that odd?
 
Mike Simmons
Ranch Hand
Posts: 3090
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, it's somewhat in conflict with what Maneesh said about what "implements" would indicate. Java's designers had a hard time being consistent about this stuff.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!