728x90 AdSpace

  • Latest News

    [Knownledge] OOP - Object-oriented programming, abstract class vs Interface

    Object-oriented programming (OOP) is a programming language model organized around objects rather than "actions" and data rather than logic. Historically, a program has been viewed as a logical procedure that takes input data, processes it, and produces output data.

    What's different about Abstract class and Interface?

    - Abstract class: is a parent class for all the classes of the same nature. (relative Is-a). We can use extends keyword in C#, php, java code
    - Interface: is a function that you can add and any class. (relative can do). We can use implements keyword in C#, php, java code.
     
    - Cùng một loại, nhóm chúng ta có thể gom thành một abstract class (Quan hệ Is - a)
    - Cùng một chức năng, chúng ta có thể gom thành một interface (Quan hệ can do)

    Xem hình bên dưới,
    - Ta có các subclass thuộc abstract class Animals and Machines
    - Ta có các Interface:Swimable, Runnable và Flyable (như ta thấy hai subclass Bolt và MCQueen là hai abstract class khác nhau, nhưng vẫn có chung interface)


    How to used Abstract class and Interface:


    OOP - Object-oriented programming, abstract class vs Interface







    OOP - Object-oriented programming, abstract class vs Interface





    Have a nice day!
    Zidane
    http://learn-tech-tips.blogspot.com/

    • Blogger Comments
    • Facebook Comments

    0 comments:

    Post a Comment

    Item Reviewed: [Knownledge] OOP - Object-oriented programming, abstract class vs Interface Rating: 5 Reviewed By: Unknown
    Scroll to Top