0

I was reading about how java avoids the deadly diamond of death, but i still have some questions. What if a class inherits a class and implements an interface and they each have a method with the same prototype? Or a method with the same name, same arguments, but different return types?

Thank you!

1
  • 2
    Why don't you try it yourself? Commented Apr 12, 2011 at 5:02

1 Answer 1

3

What if a class inherits a class and implements an interface and they each have a method with the same prototype?

If you don't override the inherited method, the compiler will assume that it's your class' implementation of the interface method. This may not necessarily be correct. It depends on the superclass' implementation.

Or a method with the same name, same arguments, but different return types?

You won't be able to implement the interface method because the compiler will think you are trying to overload the superclass method with a different return type.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.