top of page
Search

What is the difference between an abstract class and an interface?

  • Writer: Abhinaw Tripathi
    Abhinaw Tripathi
  • Jun 22, 2016
  • 1 min read

What is the difference between an abstract class and an interface?

Ans:

Abstract Class:

1.An abstract class is written when there are some common features shared by all the objects.

2.When an abstract class is written ,it is the duty of the programmer to provide sub classes to it.

3.An abstract class can contain instance variables also.

4.All the abstract methods of the abstract class should be implemented in its sub classes.

Interface :

1.An interface is written when all the features are implemented differently in different objects.

2.An interface is written when the programmer wants to leave the implementation to the third party.

3.An interface contains only abstract methods.

4.An interface can contain instance variables .It contains only constant.

5.All the methods of the interface should be implemented in its implementation classes.

 
 
 

Recent Posts

See All

Comments


© 2016 by Abhinav Tripathi

  • Facebook Clean Grey
  • Twitter Clean Grey
bottom of page