I think a proprem in this night,
As we all know,all classes's super class is java.lang.Object,
but why not it is abstract class??
Asked
Active
Viewed 79 times
-5
竹林闲人
- 1
- 1
-
Why do you think it should be? Putting your thoughts in the question would really improve it. – Natan Streppel May 07 '14 at 14:04
-
1which is itself closed as a duplicate – jwenting May 07 '14 at 14:06
-
There was a thinking that abstract classes should have abstract methods. Object could have been abstract, but it is indirectly useful that it is not as sometimes you want a generic Object. – Peter Lawrey May 07 '14 at 14:06
2 Answers
2
You could argue that it was simply an arbitrary design decision but the main benefit is that by not marking the class abstract you can create instances of type Object.
Since all of the methods of the Object class are fully implemented there was no inherent benefit in marking it abstract.
Mike Dinescu
- 54,171
- 16
- 118
- 151
2
Object does not have any abstract methods so making the class abstract would prevent it from being instantiated (although you would be able through: new Object() {};) which is an unnecessary restriction.
And it happens that being able to instantiate an Object is sometimes handy, for example to create a lock:
private final Object lock = new Object();
assylias
- 321,522
- 82
- 660
- 783