In which Scenario you will go for Interface or Abstract Class?

Answer Posted / swetcha

Interfaces, like classes, define a set of properties,
methods, and events. But unlike classes, interfaces do not
provide implementation. They are implemented by classes,
and defined as separate entities from classes. Even though
class inheritance allows your classes to inherit
implementation from a base class, it also forces you to
make most of your design decisions when the class is first
published.
Abstract classes are useful when creating components
because they allow you specify an invariant level of
functionality in some methods, but leave the implementation
of other methods until a specific implementation of that
class is needed. They also version well, because if
additional functionality is needed in derived classes, it
can be added to the base class without breaking code.

Is This Answer Correct ?    12 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

i=20;k=0; for(j=1;k-i;k+=j<10?4:3) { cout<

1407


What is purpose of inheritance?

633


What is encapsulation in oop?

599


write string class as your own class in java without using any built-in function

1964


Explain the concepts involved in Object Oriented programming.

614






What is constructor in oop?

573


What are the components of marker interface?

587


What is the difference between a mixin and inheritance?

506


Why do we use polymorphism?

559


What is encapsulation with real life example?

555


What is difference between data abstraction and encapsulation?

604


When not to use object oriented programming?

558


If a=5, b=6, c=7, b+=a%c*2. What is the final value of b?

932


What are the 3 pillars of oop?

603


What is oops and why we use oops?

561