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 8400719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:37:50+00:00 2026-06-09T21:37:50+00:00

An abstract class is the same thing as an interface except it is an

  • 0

An abstract class is the same thing as an interface except it is an actual class, not just a contract.
Why interface is refered to as a contract ?

  • 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-06-09T21:37:51+00:00Added an answer on June 9, 2026 at 9:37 pm

    Both interface and an abstract class are contracts, since they bind you.

    But there other differences between an interface and an abstract class.

    Like you said, if you need an actual class, with content to the functions or actual data members with default values, or a ctor, then obviously you will need an abstract class.

    But many times, the choose between an interface or an abstract class will be technically the same. And sometimes even in the long term, it will be the same.

    Your decision then should be based on the nature of what you are looking.

    Is it an extra character to your data types? Or does it define what your data type is?

    I’ve tried to think of any real world example, but I couldn’t find any as I haven’t done anything with the subject for years now, so I’ll give you a book-like example.

    Say we have an abstract class Animal:

    public abstract class Animal
    {
        abstract string Name;
        abstract bool IsWild;
        abstract bool IsHappy;
    }
    

    This could have been easily an interface.

    And choosing it to be an interface will actually won’t have any negative effect on your design.

    But in the matter of the nature of it, it must be an abstract class, since class Dog is an animal. It must be class Dog : Animal rather than class Dog : IAnimal.

    Being an animal is not an extra character of Dog. It what defines it.

    And you want the restrict all the animals to inherit only from Animal.

    IAnimal let someone inherit something else. like:

    public class Dog : Food, IAnimal {}
    

    Interestingly enough, sometimes one might write an abstract class with nothing at all, just for the sake of the same thing.

    For example, if there was no common property for any Animal you will still prefer to do:

    public abstract class Animal { }
    
    public class Dog : Animal // No actual added value.
    { 
            .........
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My interface declarations usually (always?) follow the same scheme. Here's an example: class Output
I have an abstract class, AbsClass that implements an interface, IClass . IClass has
interface IFolderOrItem<TFolderOrItem> where TFolderOrItem : FolderOrItem {} abstract class FolderOrItem {} class Folder :
Possible Duplicate: Why are interfaces preferred to abstract classes? Abstract class and Interface class?
I was reading a blog post here: http://codeofdoom.com/wordpress/2009/02/12/learn-this-when-to-use-an-abstract-class-and-an-interface/ public interface Actor{ Performance say(Line l);
I would like to do something like this: abstract class Foo { public function
I have a model that looks something like this: public abstract class Parent {
is it possible to do something like this in PHP 5.2.1? abstract class Test
Abstract class: abstract class PersistentList<T> public static PersistentList<T> GetInstanceOfDerivedClass() { //??? } Derived class:
abstract class base { abstract public function test(); public function run() { self::test(); }

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.