Pure object oriented programming

Question: Is java pure object oriented programming?
Answer: This has been the topic of debate for long. Java is not pure object oriented programming. Examples of pure object oriented programming language are "Ruby", "SmallTalk" etc. Below are few reasons why java is not a pure object oriented programming.
  • Java has primitive data types like int, byte, float, double, char etc. Pure object oriented programming language should contain only classes and objects. It should not contain primitive data types. Now the question comes is why java has primitive data types? It is because primitive data types are faster than objects. Primitive data type "int" takes 4 bytes where as for Integer object just the reference to the Integer takes 32 bits.
  • Java has a static keyword i.e., static fields, static methods. These are associated with the class itself, not with any particular object created from the class. You can run a program without making a single object.
  • In pure object oriented language we should access everything by message passing in other words through objects. For example, write a simple addition of two numbers inside the main() method and display the output. You can run this program without creating object.

No comments:

Post a Comment