Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 504989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:33:09+00:00 2026-05-13T06:33:09+00:00

What exactly is the difference between an interface and an abstract class?

  • 0

What exactly is the difference between an interface and an abstract class?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T06:33:10+00:00Added an answer on May 13, 2026 at 6:33 am

    Interfaces

    An interface is a contract: The person writing the interface says, “hey, I accept things looking that way“, and the person using the interface says “OK, the class I write looks that way“.

    An interface is an empty shell. There are only the signatures of the methods, which implies that the methods do not have a body. The interface can’t do anything. It’s just a pattern.

    For example (pseudo code):

    // I say all motor vehicles should look like this:
    interface MotorVehicle
    {
        void run();
    
        int getFuel();
    }
    
    // My team mate complies and writes vehicle looking that way
    class Car implements MotorVehicle
    {
    
        int fuel;
    
        void run()
        {
            print("Wrroooooooom");
        }
    
    
        int getFuel()
        {
            return this.fuel;
        }
    }
    

    Implementing an interface consumes very little CPU, because it’s not a class, just a bunch of names, and therefore there isn’t any expensive look-up to do. It’s great when it matters, such as in embedded devices.


    Abstract classes

    Abstract classes, unlike interfaces, are classes. They are more expensive to use, because there is a look-up to do when you inherit from them.

    Abstract classes look a lot like interfaces, but they have something more: You can define a behavior for them. It’s more about a person saying, “these classes should look like that, and they have that in common, so fill in the blanks!“.

    For example:

    // I say all motor vehicles should look like this:
    abstract class MotorVehicle
    {
    
        int fuel;
    
        // They ALL have fuel, so lets implement this for everybody.
        int getFuel()
        {
             return this.fuel;
        }
    
        // That can be very different, force them to provide their
        // own implementation.
        abstract void run();
    }
    
    // My teammate complies and writes vehicle looking that way
    class Car extends MotorVehicle
    {
        void run()
        {
            print("Wrroooooooom");
        }
    }
    

    Implementation

    While abstract classes and interfaces are supposed to be different concepts, the implementations make that statement sometimes untrue. Sometimes, they are not even what you think they are.

    In Java, this rule is strongly enforced, while in PHP, interfaces are abstract classes with no method declared.

    In Python, abstract classes are more a programming trick you can get from the ABC module and is actually using metaclasses, and therefore classes. And interfaces are more related to duck typing in this language and it’s a mix between conventions and special methods that call descriptors (the __method__ methods).

    As usual with programming, there is theory, practice, and practice in another language 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 298k
  • Answers 298k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer By default, IIS will only serve files for which the… May 13, 2026 at 7:27 pm
  • Editorial Team
    Editorial Team added an answer As xcut says, there is no easy way to do… May 13, 2026 at 7:27 pm
  • Editorial Team
    Editorial Team added an answer Two things need to be done to solve this issue:… May 13, 2026 at 7:27 pm

Related Questions

I'm pretty new to the Spring Framework, I've been playing around with it and
After much help from all my StackOverFlow brethren, I managed to create a C++
I have two webservices that have exactly the same methods and signatures but point
An interview question for a .NET 3.5 job is What is the difference between
Maybe I'm missing it somewhere in the PHP manual, but what exactly is the

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.