Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt in Interface

 
Sunil atluri
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
Can a abstract class extend an interface.?
 
Chris Allen
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ummm, I don't think you can extend an interface with a class. You can however implement an interface with an abstract class as shown below:


You can also extend an interface with another abstract interface as shown below:


Does this answer your question?
 
Mike Gershman
Ranch Hand
Posts: 1272
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the Java Language Specification:
9.1.1.1 abstract Interfaces
Every interface is implicitly abstract. This modifier is obsolete and should not be used in new programs.
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
short answer: no.
Classes can never extend interfaces just as interfaces can never extend classes.

Interfaces extend interfaces, classes extend classes.

Classes (whether abstract or not) can IMPLEMENT interfaces.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic