Welcome to Questionaries, where you can ask questions and receive answers from other members of the community.

Let us know at info@questionaries.org

Why are the interfaces more flexible than abstract classes?

7 like 0 dislike
Hello
Why are the interfaces more flexible than abstract classes?
please reply me. i am waiting for your reply.
Thanx
asked 1 year ago by eagles11 (179,830 points)

1 Answer

1 like 0 dislike
 
Best answer
--An interface-defined type can be implemented by any class in a class hierarchy and can be extended by another interface. In contrast, an abstract-class-defined type can be implemented only by classes that subclass the abstract class.
--An interface-defined type can be used well in polymorphism. The so-called interface type vs. implementation types.
--Abstract classes evolve more easily than interfaces. If you add a new concrete method to an abstract class, the hierarchy system is still working. If you add a method to an interface, the classes that rely on the interface will break when recompiled.
--Generally, use interfaces for flexibility; use abstract classes for ease of evolution (like expanding class functionality).
answered 1 year ago by DBA-boss (120,990 points)

Related questions

3 like 0 dislike
0 answers
4 like 0 dislike
1 answer
4 like 0 dislike
1 answer
asked 1 year ago by eagles11 (179,830 points)
4 like 0 dislike
1 answer
4 like 0 dislike
1 answer
asked 1 year ago by DBA-boss (120,990 points)