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

  • SEARCH
  • Home
  • 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 3635610
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T00:55:32+00:00 2026-05-19T00:55:32+00:00

Possible Duplicates: purpose of interface in classes What is the difference between an interface

  • 0

Possible Duplicates:
purpose of interface in classes
What is the difference between an interface and abstract class?

Hi I am a php programmer. any body can explain what is the advantage of using interface and 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-19T00:55:33+00:00Added an answer on May 19, 2026 at 12:55 am

    The main advantage of an interface is that it allows you to define a protocol to be implemented for an object to have some behavior. For example, you could have a Comparable interface with a compare method for classes to implement, and every class that implements it would have a standardized method for comparison.

    Abstract classes allow you to define a common base for several concrete classes. For example, let’s say you wanted to define classes representing animals:

    abstract class Animal {
        abstract protected function eat();
        abstract protected function sleep();
        public function die() {
            // Do something to indicate dying
        }
    }
    

    In this case, we define eat() and sleep() as abstract because different types of animals (e.g. lion, bear, etc.) that will inherit from Animal eat and sleep in different ways. But all animals die the same way (don’t hold me to that), so we can define a common function for that. Using an abstract class helped us 1.) declare some common methods that all Animals should have, and 2.) define common behavior for Animals. So, when you extend Animal, you won’t have to rewrite the code for die().

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

Sidebar

Related Questions

Possible Duplicate: What's the difference between <b> and <strong>, <i> and <em>? The purpose
Possible Duplicate: What is the purpose of a marker interface? Is it bad practice
Possible Duplicates: Public Data members vs Getters, Setters Purpose of private members in a
Possible Duplicates: Do Hibernate table classes need to be Serializable? What does Serializable mean?
Possible Duplicate: Why doesn't delete set the pointer to NULL? Is there any purpose
Possible Duplicate: What are the differences between struct and class in C++ http://www.cplusplus.com/reference/std/typeinfo/type_info/ I
Possible Duplicates: Purpose of struct, typedef struct, in C++ typedef struct vs struct definitions
Possible Duplicates: C++0X when? When will C++0x be finished? When will C++0x be released?
Possible Duplicate: Interfaces: Why cant I seem to grasp them? What is the purpose
Possible Duplicates: Why is lock(this) {...} bad? In C# it is common to use

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.