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

Let us know at info@questionaries.org

What is an interface and what is an abstract class?

2 like 0 dislike
What is an interface and what is an abstract class?
 Please, expand by examples of using both. Explain why.
asked 1 year ago by marck_don (191,010 points)

1 Answer

1 like 0 dislike
 
Best answer
In a interface class, all methods are abstract without implementation where as in an abstract class some methods we can define concrete. In interface, no accessibility modifiers are allowed. An abstract class may have accessibility modifiers. Interface and abstract class are basically a set of rules which u have to follow in case u r using them(inheriting them).

Abstract classes are closely related to interfaces. They are classes that cannot be instantiated, and are frequently either partially implemented, or not at all implemented. One key difference between abstract classes and interfaces is that a class may implement an unlimited number of interfaces, but may inherit from only one abstract (or any other kind of) class. A class that is derived from an abstract class may still implement interfaces. 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.
answered 1 year ago by daneim (127,080 points)

Related questions

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