Question : - for Extends

0 Kshitij Totare · October 11, 2016
If doing implements to other class, we need to override every method in our class to use other class methods then why can't we just use "extends" instead of  "implements"...with "extends" I don't think so we need to override any methods or need to do :(???

Post a Reply

Replies

Oldest  Newest  Rating
0 Gary Whitney · October 12, 2016
Extends is for sub-classing an Class and implements is for using an interface. ( a Class can only extend one class)
If the interface requires you to override a method then you have to override the method. Usually because the method  in the interface is just a template to provide a behavior and doesn't do anything.
0 Nicholas Eason · October 13, 2016
The reason you have to copy all of the methods of an interface when you implement it is because they are abstract. This provides some benefits. You can group objects of different classes by an interface and call all of the classes methods that are in the interface.

If you were capable of extending the interfaces, you'd still have to copy the methods. Like I said previously, interfaces are abstract, and when you extend or implement something abstract, you have to define all of their abstract methods.
  • 1

Java / Android Development

131,103 followers
About

Very popular language used to create desktop applications, website applets, and Android apps.

Links
Moderators
Bucky Roberts Administrator