Reputation: 26548
Actually till date What I know about java object class is it has methods like we have clone(), toString() but somebody told me it contains variables also. So what are those variables. Went through google. Does anybody know anything which variable it contains.
Upvotes: 0
Views: 70
Reputation: 2421
Java Object doesn't have any fields. You can see the source yourself to validate.
But yes whenever an object is created , a monitor is also created alongside to handle the locking on that object. Similarly jvm keeps a track of number of threads requesting lock on the object, these variable are not part of java object, but associated. I guess the interviewer was hinting at those.
Upvotes: 1
Reputation: 8202
It doesn't contain any fields. You should be able to open the source code from your Java installation and confirm this for yourself.
Upvotes: 1