2

If you have an interface (Position) with 3 methods (x(), y() and z()) and also have an abstract class, lets call it Shape.

Shape implements Position and only gives code to x() and y(). Does the compiler implicitly guess that z() is an abstract method?

5 Answers 5

3

Yes. So long as Shape is abstract it is not required to implement all methods of Position. That will be required of any concrete class.

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

Comments

3

The java compiler adds public and abstract keywords before the interface method and public, static and final keywords before data members.

enter image description here

Comments

0

yes, because you wont be able to instantiate the abstract class (Shape), compiler knows the z() will be implemented by some other child class (of Shape).

Comments

0

Abstract classes need not implement all methods. That's the responsibility of their concrete class/implementations. In this case, yes z() will be treated as abstract method of Shape.

Comments

0

every non-abstract class will have to provide implementation for all of the methods defined in any of it's abstract superclasses or interfaces. Compiler is clever enough to check the whole hierarchy of classes to determine that you forgot to implement something that your class claims to provide implementation for.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.