Skip to content
  • Facebook
GeekCer Logo

GeekCer

The geek's Coding education and Review centre

  • Home
  • Tutorials
    • Java
    • Servlet
    • JSP
    • Python
    • C Tutorial
    • Spring
    • Spring Boot
    • MongoDB
    • Hibernate
    • Data Structure
  • General Knowledge
  • Biography
  • Grammar
  • Festival (त्योहार)
  • Interview
  • Differences
  • Important
  • Toggle search form

Home » Differences » Difference between Interface and Abstract class

  • Pythagorean Theorem in Hindi, Definition
    Pythagorean Theorem in Hindi, Definition, Formula, Proof पाइथागोरस थ्योरम क्या है जानिए हिंदी में? Science
  • Jagannath Rath Yatra History in Hindi | जगन्नाथ पुरी की कहानी
    Jagannath Rath Yatra History in Hindi | जगन्नाथ पुरी की कहानी Festival
  • What is Verb
    What is Verb? Types of Verbs and Examples Grammar
  • Gautama Buddha life story in Hindi, Buddha's history
    Gautama Buddha life story in Hindi, Buddha’s history Biography
  • Vedaant Madhavan Biography in Hindi, Family, School, Age
    Vedaant Madhavan Biography in Hindi, Family, School, Age Biography
  • Draupadi Murmu Biography In Hindi | द्रौपदी मुर्मू की जीवनी
    Draupadi Murmu Biography In Hindi | द्रौपदी मुर्मू की जीवनी Biography
  • Indian Navy Day
    Indian Navy Day: जल सेना दिवस कब और क्यों मनाया जाता है? General Knowledge
  • What is Tense in Hindi (काल क्या है)?
    What is Tense in Hindi (काल क्या है)? Grammar

Difference between Interface and Abstract class

Posted on August 15, 2021October 4, 2021 By GeekCer Education No Comments on Difference between Interface and Abstract class
Difference between Interface and Abstract class

We can achieve abstraction using both interface and abstract class where we declare abstract methods. Further we will discuss the difference between Interface and Abstract class and basic concept of abstract method.

Table of Contents

    • Abstract Class
    • Interface
  • Interface Vs Abstract class
      • Summary of this page

Abstract Class

Before abstract class, let’s know about the abstract method in java. Abstract method is incomplete method which contains only the method header, doesn’t contain body,

Abstract class is a class that contains 0 or more abstract methods. In addition to abstract methods, it contains instance variables and concrete methods. The most important thing is you cannot create an object of the abstract class.

To use the abstract class first we create a subclass of this class and then we create a reference of abstract class.

Interface

Interface contains only the abstract methods and it is not possible to create an object of interface. But we can create separate classes where we implement al the methods of the interface.

All the methods of the interface are public and abstract by default.

Interface Vs Abstract class

There are following differences between Interface and Abstract class:

#InterfaceAbstract Class
1If we don’t know anything about implementation but just we have requirement specification we should go for interface.If we are taking about implementation but not completely then we should go for abstract class.
2The interface keyword is used to declare interface.The abstract keyword is used to declare abstract class.
3An interface can extend another Java interface only.An abstract class can extend another Java class and implement multiple Java interfaces.
4Variables declared in a Java interface are by default final.But an abstract class may contain non-final variables.
5The interface has only static and final variables.Abstract class can have final, non-final, static and non-static variables.
6We can’t declare interface method with private, protected, final, static, synchronized, native, strictfp.There is no restriction on abstract class method modifiers.
7We can’t declare interface variable with private, protected, transient, volatile.There is no restriction on abstract class variable modifiers.
8For interface variables compulsory we should perform initialization at the time of declaration otherwise we will get compile time error.Not required to perform initialization at the time of declaration in case of abstract class.
9Inside the interface we can’t declare instance and static block otherwise we will get compile time error.Inside the abstract class we can’t declare instance and static block.
10You cannot declare any constructor inside the interface.Here we can declare constructor inside the abstract class, which will be executed at the time of child object creation.
Abstract class Vs Interface

Summary of this page

Above you learned about the difference between abstract class and interface along with the basic idea about abstract method. This is the most asked topic in interface for programmers because in every application the interface and abstract class are used.

Share this:

  • Click to share on Facebook (Opens in new window)
  • Click to share on WhatsApp (Opens in new window)
  • Click to share on Twitter (Opens in new window)
  • More
  • Click to share on LinkedIn (Opens in new window)
  • Click to share on Pinterest (Opens in new window)

Also Read

Differences, Java

Post navigation

Previous Post: Difference between JPanel and JFrame
Next Post: Difference between TCP and UDP | TCP vs UDP examples

More Related Articles

Difference between SOAP and REST Difference between SOAP and REST Differences
Java Vector Vector in Java Collection, Constructors, Example Programs Java
Java Learning Tutorial Java Tutorial for Advanced Learning, Buzzwords, Parts of Java Java
What is Array in Java? Types of array in Java What is Array in Java? Types of array in Java Java
Lambda Expression in Java 8 | Functional Interface | Example Lambda Expression in Java 8 | Functional Interface | Example Java
Difference between Git Merge and Git Rebase | Git Rebase vs Git Merge Difference between Git Merge and Git Rebase | Git Rebase vs Git Merge Differences

Leave a Reply Cancel reply

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

  • National Farmers Day in Hindi | राष्ट्रीय किसान दिवस पर निबंध | चौधरी चरण सिंह जयंती
  • Human rights day in Hindi: 10 दिसंबर ह्यूमन राइट्स डे
  • Unicef day is celebrated on December 11 | Speech on unicef day
  • Indian Navy Day: जल सेना दिवस कब और क्यों मनाया जाता है?
  • P V Sindhu Biography in Hindi, Badminton, State, Caste पी. वी. सिंधु जीवन परिचय, कहानी, राज्य, जाति
  • Draupadi Murmu Biography In Hindi | द्रौपदी मुर्मू की जीवनी
  • Network kya hai (नेटवर्क क्या है)
    Network kya hai (नेटवर्क क्या है) Networking
  • Difference between TCP and UDP
    Difference between TCP and UDP | TCP vs UDP examples Differences
  • OSI Model | 7 Layers of OSI Model in Computer network
    OSI Model | 7 Layers of OSI Model in Computer network, Functions Networking
  • Similarities and difference between OSI and TCP/IP model
    OSI vs TCP/IP Model, Similarities and difference between OSI and TCP/IP model Networking
  • Difference between Internet and Intranet
    Difference between Internet and Intranet Differences
  • TCP/IP Model, Full Form, Layers and their Functions
    TCP/IP Model, Full Form, Layers and their Functions Networking
  • IPv4 Vs IPv6 | Difference between IPv4 and IPv6
    IPv4 Vs IPv6 | Difference between IPv4 and IPv6 Differences
  • Java Tutorial
  • Servlet Tutorial
  • JSP Tutorial
  • Maven Tutorial
  • HTML Tutorial
  • Programs
  • Hindi/English Grammar
  • Difference Between ... and ...
  • HR Interview
  • Important Articles

Write to Us:
geekcer.code@gmail.com

  • About Us
  • Privacy and Policy
  • Disclaimer
  • Contact Us
  • Sitemap

Copyright © GeekCer 2022 All Rights reserved