Abstract Class
Class declared with Abstract keyword is known as abstract class in java.  This abstract class have abstract and non-abstract methods. Basically abstract is a process of hiding the properties and showing only functionality to the user. It shows only important things to the user and hides the internal details.

abstract class ClassOne
{
abstract public void method();
public void method1()
{
System.out.println("Method");
}
}
class ClassTwo extends ClassOne
{
public void method()
{
System.out.println("Method 2");
}
}

 
Interfaces
It is not a class, all methods declared in this block are incomplete. Interface block should be declared with ‘interface’ keyword.  Interface is a blueprint of class. Java core part and a way to achieve data  abstraction in java along with abstract class.  Multiple interface implementation allows to implemented subclass. It is fully abstract class. Here no need to declare abstract keyword and no need to declare interface keyword for all methods.  Let see the example.

interface Program1
{
public void method1();
}
class MyProgram1 implements Program1
{
public void method1()
{
System.out.println("hello this is overrided method..");
}
}

Difference between Abstract class and Interface

Abstract classInterface
It can have abstract and non abstract methods.It can have only abstract methods.
abstract keyword is used to declare abstract classinterface keyword is used to declare interface.
It can contain static methods, main method and constructor.It cannot contain static methods, main method or constructor.
It does not support multiple inheritance.It supports multiple inheritance.
It can have final, non-final, static and non-static variables.It has only static and final variables.
It can provide the implementation of interface.It cannot provide the implementation of abstract class.

Leave a Reply

Your email address will not be published. Required fields are marked *

Solve : *
22 − 3 =