Vagdevi Malla wrote:
I mean why class implements interface?
why can't class implements class?
Chan Ag wrote:Ihsan Cingisiz, Welcome to Coderanch.
Chan Ag wrote:
I mean why class implements interface?
why can't class implements class?
Simple answer - that is by design.
Ihsan Cingisiz wrote:Hi, it is called "Inheritance". Implements is used to implement interfaces, while extends is used to
extend an existing class.
When you implement interfaces in a specific class, you are required to override the methods inside the
interface you have implemented in your existing class. The main reason why one uses interfaces has also
to do with multiple implementations while you only can extend just one class.
And, when you extend an existing class, you can use the methods inside of it and more (see link below).
Please take a look at: Oracle Inheritance
I hope that will make it a bit clear for you. You should read the Oracle Documentation on Java OO. These
are the basic things that you actually in my opinion have to know if you are a programmer.
- Ihsan.
Oracle Certified Associate : Java 7
methods of implemented interfaces are not overridden since they have no body to start with, you're simply providing an implementation for these methods, not overridde them.
a java class can implement multiple interfaces but cannot implement/extend multiple classes
My cellmate was this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
|