• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Interface doubt from K&B

 
dhwani mathur
Ranch Hand
Posts: 621
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all!!
i have a doubt from K&B book,i read the topic Interface it is given that an interface can extend another interface.
My question is that If Interface AB extends Interface AC than

1)if any class say A implements interface AB is it compulsory for the class A to write the defination of methods defined in interface AC bcoz AC interface extends Interface AB?or it can just implement methods of interface AB?

2)for extending interface is that we just need to use "extends"?
And one more question is can class A implement only the "interface AC"...and not interface AB?

please if anyone could clear my doubt,it will be kinda of you.Thanks in advance
 
Nik Arora
Ranch Hand
Posts: 652
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Dhwani,
If interface AB extends AC as you have mentioned then if class A implents AB then both the interface methods has to be defined in class A.

If you want to implement only AC interface you can do that and define only the methods in AC interface.

There is only keyword extends if one interface wants to extend another interface.

Regards
Nik
 
dhwani mathur
Ranch Hand
Posts: 621
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi nik!!
Thank you for your explanation!!i got my answer!!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic