java - Extended Class And implemented interface having same method name -


in java, if have classa extends classx , implements interfacey, , both classx , interfacey have methodc(), why don't have give implementation of methodc() in classa? kind of method overloading ?

because if classx has implementation of methodc() , classa extends classx, classa does have implementation of methodc() - classx's implementation of it.

if classa has it's own implementation of methodc(), called method overriding - classa's implementation override implementation of super class (classx).

overloading different issue entirely: overloading occurs when class has multiple methods same name/return type take different parameters. useful when want able perform same or similar operations different inputs, , has nothing overriding, useful when have subclass implementation of particular method needs different of super-class.

see here helpful discussion differences between them.


Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -