not implementing all of the methods of interface. is it possible?

前端 未结 10 1960
挽巷
挽巷 2020-11-28 03:33

Is there any way to NOT implement all of the methods of an interface in an inheriting class?

10条回答
  •  孤独总比滥情好
    2020-11-28 04:15

    We can use Adapter classes ,which reduces complexcity by not making mandatory to implement all the methods present in the interface

    Adapter class is a simple java class that implements an interface with only EMPTY implementation . Instead of implementing interface if we extends Adapter class ,we provide implementation only for require method

    ex--- instead of implementing Servlet(I) if we extends GenericServlet(AC) then we provide implementation for Service()method we are not require to provide implementation for remaining meyhod..

    Generic class Acts as ADAPTER class for Servlet(I).

提交回复
热议问题