What is class , abstract class & interface .

Published: (December 11, 2025 at 12:35 AM EST)
1 min read
Source: Dev.to

Source: Dev.to

Cover image for What is class , abstract class & interface .

What is class ?

  • A class is a blueprint from which we create objects.
  • We declare a class with the class keyword.
  • Inside the class we can directly write fields (non‑static / static), blocks (non‑static / static), constructors, concrete methods (non‑static / static), inner classes, interfaces, and so on.
  • Generally, we create an object of a class with the new keyword.
  • A class is also a user‑defined data type.
  • We cannot write abstract methods inside a normal class.

class diagram

Abstract Class

  • An abstract class is declared with the abstract keyword.
  • We cannot create an object of an abstract class.
  • An abstract class may contain:
    • Non‑abstract (concrete) methods
    • Abstract methods
    • Non‑static fields
    • Static fields
  • An abstract class cannot be final.

Note

  • An abstract method has no body; its implementation must be provided in a subclass.

abstract class diagram

Interface

  • An interface is a blueprint that contains abstract methods and constant (public static final) variables.
  • We declare an interface with the interface keyword.
  • Using interfaces we can achieve multiple inheritance.

interface diagram

Back to Blog

Related posts

Read more »

What is object & class in java

What is Object? Object is a real‑world entity having properties and behaviors. For example, a pen can have properties such as color, brand, height, and diame...

Method overriding in Java

What is method overriding When a subclass provides a specific implementation for a method that is already defined in its parent class, it is called method over...

First-Class Functions in JavaScript

Introduction For developers learning JavaScript, the term first‑class functions appears frequently in discussions and documentation. In JavaScript, functions a...