Purely Object Oriented Languages [duplicate] - java

This question already has answers here:
Is java Purely Object Oriented?
(12 answers)
Closed 6 years ago.
What does the term Purely Object Oriented mean in case of Programming Languages? Is Java a purely Object Oriented and which languages come under this category? I've often read that Purely Object Oriented languages are one in which everything comes in form of objects and so can anyone clarify the confusion.

Java still has the primitives like short , int , long , float and double
these are not considered objects. However, in ruby for example everything,
including the numbers are objects.

Related

What's the point of Interfaces? [duplicate]

This question already has answers here:
When should one use interfaces?
(19 answers)
Closed 5 years ago.
I'm having trouble understanding why I should use interfaces, and how I should integrate them into my current project. I use a lot of polymorphism already, and I usually see polymorphism and interfaces side by side in other projects of my peers.
Why do you use interfaces? What are the real benefits?
This question has already been answered in:
When should one use interfaces?
What is an interface in Java?
Java Interfaces?
To get more information about OOP design you can also refer to books like Head First: Object oriented analysis and design. There are also some on-line courses on platforms like Coursera and Edx that you can use.

Is Java a "completely" object-oriented language? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
Recently at a job interview I was asked "Is Java a "completely" object-oriented language?"
As I was completely unable to answer that question and do not know the answer, could someone, please, help me to understand the nature of this question.
As I see the question is being closed as "opinion-based" that's not an opinion I'm asking. I'm asking if I am unaware of that completely/incompletely category.
Kindly tell me if that's a wrong forum to ask this.
Java has primitives. Primitives are not Objects.
Depends on how you look at it, but yes, as #biziclop said, it's a matter of opinion.
To break it down, Java is, as you know, an object oriented language, but it's still possible to do functional programming in it (a static method that takes a primitive argument and returns a result).
Since primitives are not objects you can do non-object programming with Java.
So technically, no, Java is not a completely object-oriented language.
No. Java is not because it supports Primitive datatype[^] such as int, byte, long... etc, to be used, which are not objects.
There are seven qualities to be satisfied for a programming language to be pure Object Oriented. They are:
Encapsulation/Data Hiding
Inheritance
Polymorphism
Abstraction
All predefined types are objects
All operations are performed by sending messages to objects
All user defined types are objects
well Java is not 100% object oriented, because it still contains Primitive datatype
for example:
int i=0;
here i is not an object but contains the actual value.
However,
Set<String> set=new HashSet<String>();
set is a refrence that referes to a HashSet

Primitive vs Object type in Java [duplicate]

This question already has answers here:
Why do people still use primitive types in Java?
(21 answers)
Closed 9 years ago.
This question came to my mind because I have read somewhere that Java is not a pure Object oriented language since it is using primitives (which are not objects). I can agree with that. Now my problem is why we are using primitives/wrappers while we already have Object in same type?
As an example if we consider Integer, It has same value limit as int other than object behavior. why still Java use primitives under these condition?
As my opinion, if Java only use Object type Autoboxing and Unboxing no need. Also there is no primitive for String by the way.
One reason is due to memory usage. Primitives, such as int, float etc. require less memory allocations (I think 4 bytes) in comparison to Objects which are at the very least 8 bytes. Please see the following reference:
In addition, a lot of arithmetic (numeric) is completed with the use of primitives rather than their Object equivalents and this is another reason why they are quite critical in the Java language.

Disadvantages of making Java objects immutable [duplicate]

This question already has answers here:
Downsides to immutable objects in Java? [closed]
(17 answers)
Closed 9 years ago.
An interviewer asked me about the disadvantages of making classes immutable. I gave an answer regarding the heap space that is occupied by immutable objects and how it brings down the performance of Java applications.
What are other disadvantages of making objects immutable in Java?
The disadvantage is that you must create a new object to change its "value". If your class is representing something that "changes" frequently, you'll create a lot of objects, putting load on the garbage collector.
You should also consider that it may be much more difficult to deserialize/materialize immutable objects, since it usually involves writing a class with no parameter-less constructor.
Lets take a BigInteger
BigInteger i1 = BigInteger.valueOf(1);
it has add method, but you cannot add 1 to it, it's immutable, so what you do is
BigInteger i2 = i1.add(i1);
that is, a new object is created each time, ie arithmetic with immutable BigInteger is very slow
If there is no application requirement that your object be mutable, there is no disadvantage to making it immutable and you should do so.
If there is an application requirement your object is mutable, then make it mutable.

Is there an accepted Java equivalent to Python's zip()? [duplicate]

This question already has answers here:
How to most elegantly iterate through parallel collections?
(8 answers)
Closed 6 years ago.
I've got two List objects and I want to pair them up, just like the zip() function in Python. I'm pretty sure this isn't available in the JDK, but is there something like this in a fairly widespread library, similar to Apache Commons Collections? Thanks.
Functional Java has zip, zipWith and zipIndex the way you would expect from Haskell or Scala. (Indeed, the authors are pretty much all Haskell programmers.)

Categories