• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Interfaces

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
X extends Y mean? Does it mean that X and Y are either classes or interfaces.

I thought extends keyword can be used only to classes & interfaces used implements keyword.
Please clear my doubt.
 
Ranch Hand
Posts: 145
Oracle Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Keyword extends can be used with classes and interfaces both e.g.

class A{}

class B extends A{} // valid

class X{}

class C extends A,X{} // multiple inheritence is not supported on classes

interface I{}

interface J extends I{} // valid

interface K{}

interface L{}

interface M extends J,K,L {} // valid multiple inheritence is supported on interfaces

class A extends I{} // invalid as class class cannot extend interface

interface O extends A{} // invalid as inteface cannot extend class

I hope its clear, any questions, you are welcome.
 
snakes are really good at eating slugs. And you wouldn't think it, but so are tiny ads:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic