Abstract class

Total Post:113

Points:791
Java 
 110  View(s)
Ratings:
Rate this:

What is Abstract class and Interface in Java ?

  1. Post:140

    Points:984
    Re: Abstract class

    Abstract class and Interface in Java :

    Declaration: 

    Abstract class is declared using 'abstract' keyword .Interface is declared using 'interface' keyword .

    Methods: 

    Abstract class may contain abstract or concrete methods We can define abstract, default and static methods in an Interface.Access modifiers 

    Implementation: 

    Abstract class can not be instantiated but can be extended.Interface can be implemented by another class or can be extended by other interfaces Multiple inheritance. 

    difference feild is shown below : 

    - Methods

    - Members

    - Inheritance

    - Member variables

    - Members visibility

    - Keyword

    - main() exists

    - Flexibility

    Example : 

    1. Abstract class 

    abstract class 
    {
       abstract void absmethod1();
       abstract void absmethod2();
       void concmethod()
       {
       //concrete method
       }
    }

    2. Interface

    interface myinterface 
    {
        void method1();
        void method2();
       // no concrete method
    }

Answer

NEWSLETTER

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