difference between abstract class and interface

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #3043
    Pavan
    Member

    difference between abstract class and interface?

    #3048

    Abstract Class Vs Interface:

    1. Interface and Abstract class both are used for written business logic.
    2. There is no access specifires in Interface by default its public. Abstract class can have access specifires.
    3. Both Interface and Abstract class are inherited by child classes.
    4. In Interface we can declare only signature of methods. In Abstract class we can or can not declare body of method. But at least one method which have only signature not the body must be in Abstract class.
    5. If all the method in Abstract class has no body then Abstract class will be like Interface.
    6. Class which inherited Interface must be overriding all the methods of Interface. In Abstract it’s not necessary to override all the methods of Abstract class. If you will not override the abstract method in derive class the drive class must be mark as Abstract class.
    7. You can inherit multiple interface in derived class but only one abstract class.

    #3051
    Pavan
    Member

    Thank you shobhit It help me a lot.
    can you tell me how can i know in which condition we use Abstract Class and in which condition we use Interface.

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.