java interview question 3 || Why java is not pure object-oriented language? #java #interview

preview_player
Показать описание
Why is not pure object oriented language ?
Java is often considered to be a "mostly" or "mostly not" pure object-oriented language. Here are a few reasons why:

Primitive Data Types: Java includes primitive data types such as int, double, char, etc., which are not objects. In pure object-oriented languages, everything is treated as an object, including primitive data types.

Static Methods: Java allows the creation of static methods, which belong to the class rather than any specific instance of the class. In pure object-oriented languages, all behavior is encapsulated within objects, and there are no static methods.

Arrays: Java arrays are not true objects. They are closer to a language construct, and they don't inherit from a common superclass like other objects.

Predefined Classes: Java provides several predefined classes, like Math, which contain only static methods. This is not in line with the pure object-oriented paradigm.

Access Modifiers: Java has access modifiers like public, private, and protected, which control the visibility of classes, methods, and variables. Pure object-oriented languages do not have such modifiers because all data and behavior are encapsulated within objects.

While Java is not strictly a pure object-oriented language due to these features, it's worth noting that it still heavily relies on object-oriented principles and is often considered to be an object-oriented language in practice.
Рекомендации по теме