Mphasis Interview Question

abstract vs interface

Interview Answer

Anonymous

Mar 27, 2020

Interface is used when implementation is not known , just the req specification is known...while if we knw the implementation but a little of it go for Abstract class Interface methods are default abstract in nature, hence 100% abstraction achieved, while Abstract methods provide partial abstraction. Interface uses 'implements' keyword to implement a class .Abstract uses the worf 'extends'. Interface methods are default public(cant be declared as protected or private) and abstract(hence cant be final static synchronized native strictfp) Abstract methods can be other concrete methods. Every variable in interface is public static and final ..whether we declare or not. Every variable in abstract class maynot be public static final... For interface,compulsory declaration is necessary ..and not the same for abstract class