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

Polymorphism with an example?

8 Answers   Accenture, emc2,


what is overloading and overriding?

7 Answers  


what is mean by design pattern

4 Answers  


Is data hiding and abstraction same?

0 Answers  


write a function that takes an integer array as an input and finds the largest number in the array. You can not sort array or use any API or searching needs?

2 Answers   IBMS, Zycus Infotech,






what is oppes

2 Answers  


What is a class in oop?

0 Answers  


how do you handle yourself when you feel the wald is aganist you

2 Answers  


Describe these concepts: Polymorphism, Inheritance and Abstraction.

0 Answers   TCS,


What is multiple inheritance? Give Example

6 Answers   Mind Tree,


Why polymorphism is used in oops?

0 Answers  


What does the keyword "static" mean?

4 Answers   TCS,


Categories