Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Main concepts in OOP

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:

  • Inheritance
  • Encapsulation
  • Abstraction
  • Polymorphism

Was I correct?

like image 608
Peanut Avatar asked Dec 31 '08 13:12

Peanut


People also ask

What are the 8 concepts of OOPS?

OOps in java is to improve code readability and reusability by defining a Java program efficiently. The main principles of object-oriented programming are abstraction, encapsulation, inheritance, and polymorphism. These concepts aim to implement real-world entities in programs.

What are the 6 concepts of OOP?

Abstraction, encapsulation, polymorphism, and inheritance are the four main theoretical principles of object-oriented programming. But Java also works with three further OOP concepts: association, aggregation, and composition.


1 Answers

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

like image 125
Steven A. Lowe Avatar answered Oct 06 '22 13:10

Steven A. Lowe