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



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

Answer / 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

More OOPS Interview Questions

What is sub classing in c++?

1 Answers  


is java purely oop Language?

49 Answers   HCL, Infosys, TCS,


how does a main() in C++ is different from main() in C?

7 Answers  


What are the 4 main oop principles?

0 Answers  


How to handle exception in c++, For example in a functions i am assigning memory to some variables and also in next instructions in am dividing one variable also. If this functions generates a error while allocating memory to those variable and also while dividing the variable if i divide by zero then catch block how it will identify that this error has cone from perticular instruction

0 Answers  






Can bst contain duplicates?

0 Answers  


Why is abstraction needed?

0 Answers  


how to swap the variables without using temp and operators

1 Answers  


What normal C constructs work differently in C++?

2 Answers  


What are generic functions and generic classes?

5 Answers  


What is difference between function overloading and overriding?

1 Answers   emc2,


What is Method overloading?

5 Answers  


Categories