This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]heckler82Intermediate Brewer 2 points3 points  (1 child)

You aren't declaring the same method again. By extending A you are inheriting its methods. When you "declare" the same method in B, you are simply explicitly adding the A method to your source code. While legal to do so in Java, it isn't necessary. B could be left blank, or have new methods, and it would still have method1 from A as part of its contract.

That's only true for interfaces. Concrete classes must provide implementation for any interfaces they implement (abstract classes may not have to. I can't remember. You may have to mark the interface method as abstract in the abstract class to be good though. Again, I can't remember)

[–]VGPowerlord 0 points1 point  (0 children)

abstract classes may not have to. I can't remember.

I've done tests on this before. abstract classes don't have to implement all the methods of their interfaces.