DIFFERENTIATE BETWEEN AN ABSTRACT CLASS AND AN INTERFACE.

Sumit Kesarwani

Total Post:782

Points:3910
Posted by  Sumit Kesarwani
C# 
C#
 1206  View(s)
Ratings:
Rate this:
  1. Sumit Kesarwani

    Post:782

    Points:3910
    Differentiate between an abstract class and an interface.

    Abstract Class:

    A class can extend only one abstract class

    The members of abstract class can be private as well as protected.

    Abstract classes should have subclasses

    Any class can extend an abstract class.

    Methods in abstract class can be abstract as well as concrete.

    There can be a constructor for abstract class.

    The class extending the abstract class may or may not implement any of its method.

    An abstract class can implement methods.

    Interface

    A class can implement several interfaces

    An interface can only have public members.

    Interfaces must have implementations by classes

    Only an interface can extend another interface.

    All methods in an interface should be abstract

    Interface does not have constructor.

    All methods of interface need to be implemented by a class implementing that interface.

    Interfaces cannot contain body of any of its method.

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!