Renga's weBlog

February 6, 2009

Difference between Abstract class and Interface in PHP

S.No

Abstract Class

Interface

1

For abstract class a method must be declared as abstract. Abstract methods doesn’t have any implementation. For interface all the methods by default are abstract methods only. So one cannot declare variables or concrete methods in interfaces.

2

The Abstract methods can declare with Access modifiers like public, internal, protected. When implementing in subclass these methods must be defined with the same (or a less restricted) visibility. All methods declared in an interface must be public.

3

Abstract class can contain variables and concrete methods. Interfaces cannot contain variables and concrete methods except constants.

4

A class can Inherit only one Abstract class and Multiple inheritance is not possible for Abstract class. A class can implement many interfaces and Multiple interface inheritance is possible.
About these ads

26 Comments »

  1. Reblogged this on Блог zBujhm-а.

    Comment by zbujhmz — March 12, 2014 @ 6:12 PM

  2. It does appear, however, that hypnosis can help a person achieve his or her weight loss goals.
    It’s old news that tracking food intake could
    lead to losing a few pounds [2]. Then leave it a while until your tummy lets you know that you’re hungry again before opting for a healthy snack.

    Comment by Reynaldo — August 2, 2013 @ 7:50 AM

  3. If you find it a bit maddening to follow the
    daily fluctuations of the scale even though you are eating
    properly, pick three days of the week on which you will always weigh yourself (for example, Monday, Wednesday,
    and Friday). Cucumber contains sterols which can help to lower cholesterol and prevent carbohydrates from converting to body
    fat. Many people don’t have the time to weight themselves every day, but checking the scale on a regular basis can definitely help when you’re working to lose weight and keep it off.

    Comment by Leandra — July 25, 2013 @ 4:50 AM

  4. If you find it a bit maddening to follow the daily fluctuations of the scale even though you
    are eating properly, pick three days of the week on which you will always weigh yourself (for example,
    Monday, Wednesday, and Friday). Vinson had participants keep their
    normal diet and exercise routines (or lack thereof) and merely added the green coffee.
    Do not be tempted to lose weight as quickly as you can, because a crash diet will have you eating less than a thousand calories a day slowing down your metabolism.

    Comment by simply click the following web site — July 18, 2013 @ 10:36 PM

  5. “I will need to have some ability connected with to thank everyone concerning the quality hints We’ve got frequently liked opportunities your webpage. We’re pumped up about the graduation aiming to these kinds of secondary education taking a look at additionally your entirety placement of feet wouldn’t usually are completely finish devoid of on the way onto your website site. Plainly might be of an average assist individuals, I’ll be fortunate to be able to of what We have studied out of this point.”

    Comment by seohosting — June 27, 2013 @ 4:03 PM

  6. Major follows some sports, primarily during the playoffs.
    All that energy is boxed in, amplified by the space.
    Moreover, there you could also play Scrabble in the internet, TV game shows or game consoles.

    Comment by Bob — June 15, 2013 @ 10:45 PM

  7. The internet is fueling the success of music because it can be listened to at any time of the day and anywhere in the world.
    Regular workshops ensure that the staff at PVM Radio subdivision is not only up
    to date with the latest technological innovations, but also ensures
    that the customers from diverse backgrounds are offered the
    best possible services to suit their tastes.
    There are many websites that bring to people radio channels for their personal entertainment.

    Comment by sunrise radio uk — June 15, 2013 @ 8:36 AM

  8. “Worked All Zones Award” is the same concept with time zones.

    Often, long term schedules with a bit of breathing room work
    best. Many people will be happy with replaceable
    batteries for home use and occasional outings.

    Comment by fraupaulchenbloggt.de — June 4, 2013 @ 4:35 PM

  9. Even your indoor pool is there at your service. At Ljubljana Airport, Slovenia Paphos Car
    Hire is hardly limited just somewhat expensive. Luckily for people like us could
    be a lucrative business project. Then there are also a number of factors, all
    of that and more. Holidaymakers who have been saving carefully and
    frugally over the years. Payless paphos car hire services the Ft.
    For example, you may not realize is that you know where to take their clothes
    and belongings.

    Comment by car hire paphos airport — May 17, 2013 @ 5:21 PM

  10. No longer does a music lover need to bother about traveling
    out of range when a fantastic song comes on over the vehicle
    radio. Next, build a list of prospects and develop a relationship with those prospects on your list.
    So, a custom direct application and route tracking can make it easier to you
    cut fuel cost, save visit time and wholesome delivery.

    Comment by Latesha — May 17, 2013 @ 9:38 AM

  11. As the medium is not limited to any particular geographical or demographic
    region, advertising on internet radio would give the business an international audience base.

    As business owners recognize the swaying power of using audio to communicate the value and quality of their products and services, online audio will come of age in a
    big way. You can see if any of your Facebook friends are listening by clicking on the Facebook link on the
    bottom right.

    Comment by Charis — May 11, 2013 @ 11:17 PM

  12. Abstract classes do allow constructors to be added but interfaces don’t.See
    Abstract class and interface

    Comment by javaexp — January 2, 2013 @ 7:33 PM

  13. pathetic diff.. anyone can easily get from php.net

    Comment by M — December 6, 2012 @ 5:59 PM

  14. nice

    Comment by roopa — October 12, 2012 @ 10:57 AM

  15. good and understandable differentiation

    Comment by madhuri — September 30, 2012 @ 5:19 PM

  16. In principle, if an abstract class contains only abstract methods we’re using it as an interface.
    CONCLUSIONS
    Abstract classes are used to share functions.
    The interfaces are used to share how you have to do something.
    Source Interface VS Abstract Class in PHP

    Comment by Al — April 10, 2012 @ 2:31 PM

  17. Very good and useful, keep it up…Thanks…..

    Comment by koushik Chatterjee — March 5, 2012 @ 8:56 AM

  18. […] Difference between abstract classes and interfaces […]

    Pingback by Interface vs. Abstract class en PHP – castellano « Alessio Mavica — September 12, 2011 @ 11:21 PM

  19. […] Difference between abstract classes and interfaces […]

    Pingback by Interface vs. Abstract class in PHP – italiano « Alessio Mavica — September 12, 2011 @ 11:20 PM

  20. Abstract Classes

    1. An abstract class can provide some functionality and leave the rest for derived class
    2. The derived class may or may not override the concrete functions defined in base class
    3. The child class extended from an abstract class should logically be related

    Interface

    1. An interface cannot contain any functionality. It only contains definitions of the methods
    2. The derived class must provide code for all the methods defined in the interface
    3. Completely different and non-related classes can be logically be grouped together using an interface

    Comment by ehandmadepaper — May 23, 2011 @ 11:04 AM

  21. einnahme generisches flagyl http://pillen.kilu.de/apotheke/einnahme-generisches-flagyl.html – einnahme generisches flagyl einnahme generisches flagyl nebenwirkung von lasix nephrotisches syndrom http://pillen.kilu.de/apotheke/nebenwirkung-von-lasix-nephrotisches-syndrom.html – nebenwirkung von lasix nephrotisches syndrom nebenwirkung von lasix nephrotisches syndrom lasix ohne rezept bestellen http://pillen.kilu.de/apotheke/lasix-ohne-rezept-bestellen.html – lasix ohne rezept bestellen lasix ohne rezept bestellen lasix howto http://pillen.kilu.de/apotheke/lasix-howto.html – lasix howto lasix howto

    Comment by PriduralBT — March 10, 2011 @ 6:32 PM

  22. nice

    Comment by haresh — November 2, 2010 @ 5:01 PM

  23. It seems not true that Abstract class can’t have an implementation of a method? An I right… e.g. http://www.developer.com/lang/php/article.php/3604111/PHP-5-OOP-Interfaces-Abstract-Classes-and-the-Adapter-Pattern.htm

    Comment by Luka — October 5, 2010 @ 11:12 PM

  24. Good differentiation :)

    Comment by Rajeev — September 14, 2010 @ 4:54 PM

  25. dsfsadf

    Comment by fgdgsd — October 6, 2009 @ 4:37 PM

  26. All methods declared in an interface mustn’t be private or final but it may be public, static etc.

    Comment by sasikant — May 7, 2009 @ 7:18 PM


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

The Silver is the New Black Theme. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: