Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Java is not OOP is now proved

  Asked By: Bogart    Date: Jul 07    Category: Java    Views: 720
  


According to definition of an object "It is an entity that can maintain its
state .... ".
No in Java (and also in C# for that matter) I can make class that cannot
maintain its state, but can still exist as an object in the Java world, for
e.g.,

class Test {
public void aFunc() {
System.out.println("I cannot maintain my state, as I don't
have any variables!!!");
}
}

Can be instatiated as an object (I can write Test a = new Test();
a.aFunc();).
Now this object has no variable/attribute, so it cannot maintain its state
over time. But java still allows its object to be created. According to me
this is an illegal object, or direct voilation of the definition.

I think that any claims for Java/C# being an OOP language should be taken
back.

Share: 

 

3 Answers Found

 
Answer #1    Answered By: Norman Ray     Answered On: Jul 07

You read "It is an entity  that can maintain  its state" as "It is an entity that
must maintain its state", which is incorrect. By the definition  you gave, Java
is indeed an OOP language.

 
Answer #2    Answered By: Leon Evans     Answered On: Jul 07

You are wrong. Your test object  does have a state,
as any new class, by default, extends
java.lang.Object. If you want to ry it, just call the
a.toString() method and print out the results. As you
create multiple test  objects they will all have
different states.

On the other note, even if your Test object had no
member variables (fields), it would have an empty
state which is also a state, similar to the way an
empty set is a set in math.

 
Didn't find what you were looking for? Find more on Java is not OOP is now proved Or get search suggestion and latest updates.




Tagged: