Main concepts in OOP

后端 未结 14 2114
夕颜
夕颜 2020-12-07 17:03

I was once asked in an interview \'What are the 3 main concepts of OOP?\'. I answered by saying that in my opinion there were 4 which are as follows:

  • Inheritan
相关标签:
14条回答
  • 2020-12-07 17:44

    Most people would consider that correct, my guess is if they were asking for three it would be Inheritance, Encapsulation and Polymorphism.

    I personally find that those three concepts are the real "meat" if you will behind the definition of OOP. And most people take abstraction for granted and lum it in with the others, as really it could be considered part of any of the other three.

    When I talk about OOP though I always mention the 4.

    0 讨论(0)
  • 2020-12-07 17:46

    There are 3 requirements for a language to be object-oriented:

    • a language that supports only encapsulation (objects) is not object-oriented, but it is modular
    • a language that supports just encapsulation (objects) and message-passing (polymorphism) is not object-oriented, but it is object-based
    • a language that supports encapsulation (objects), message-passing (polymorphism), and inheritance (abstraction), is object-oriented

    NOTE: Abstraction is a much more general concept; encapsulation et al are kinds of abstraction, just as a subroutine is a kind of abstraction. See Abstraction

    0 讨论(0)
提交回复
热议问题