Is Java object-oriented?

This is often asked at interviews. I’ll explain when to answer “yes” and when to answer “no”.

Object-oriented programming (OOP) is a paradigm. Java is a object-oriented programming language, simply because Java is designed to support that paradigm. But it also supports other paradigms, such as concurrent computing and with Java 8 even a bit of functional programming.
But as a multi-paradigm language it is not purely object-oriented. Examples of purely object-oriented languages are usually Smalltalk and Eiffel.

What to answer?

If they ask if it is object-oriented or if it supports OOP:

Say that it does support OOP and that this paradigm always was very important for Java.

If they ask if it is purely object-oriented:

No, because primitives aren’t objects. Methods are also not objects (compare that to JavaScript where a Function is actually an Object and can have properties). And then there is the static keyword, which would not be needed in a purely object-oriented language.

Common answers on other blogs/sites

It is OOP because even a “Hello World” needs objects.

That’s actually correct, because the String “Hello World” is an object, you get an array of Strings (usually called args), and System.out is an object of type PrintStream. But that also shows that many things in Java aren’t objects. The application itself isn’t an object. There is no instance of your main class. Even the main method is not an object. Java isn’t pure, but you can’t use Java without using objects.

It uses objects so it is object oriented.

C++, ObjectPascal, and PHP also have objects. But all three are languages that evolved from languages that had no objects at all (C, Pascal, PHP/FI, resp.). So that isn’t such a good answer. Java is also influenced by such languages as C and Pascal.
I’ve seen code that was ported from such procedural languages and they kept the design. There was no object-oriented design. Java supports that very well, you can just make everything static. Other than strings and arrays you don’t need to use any objects.

One thought on “Is Java object-oriented?”

Leave a Reply

Your email address will not be published. Required fields are marked *