Abstract Class and Interface in Java – A Beginner’s Guide

Abstract Class in Java

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<br>
{<br>
abstract public void method();<br>
public void method1()<br>
{<br>
System.out.println("Method");<br>
}<br>
}<br>
class ClassTwo extends ClassOne<br>
{<br>
public void method()<br>
{<br>
System.out.println("Method 2");<br>
}<br>
}<br>

Interfaces in Java

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<br>
{<br>
public void method1();<br>
}<br>
class MyProgram1 implements Program1<br>
{<br>
public void method1()<br>
{<br>
System.out.println("hello this is overrided method..");<br>
}<br>
}<br>

Difference between Abstract class and Interface in Java

Abstract class Interface
It can have abstract and non abstract methods. It can have only abstract methods.
abstract keyword is used to declare abstract class interface 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.

About the Author

Software Developer | Technical Research Analyst Lead | Full Stack & Cloud Systems

Ayaan Alam is a skilled Software Developer and Technical Research Analyst Lead with 2 years of professional experience in Java, Python, and C++. With expertise in full-stack development, system design, and cloud computing, he consistently delivers high-quality, scalable solutions. Known for producing accurate and insightful technical content, Ayaan contributes valuable knowledge to the developer community.