+ 1

Can some please explain the Object class?

Simple example will be helpful

23rd Jul 2016, 5:49 PM
tshoswane
tshoswane - avatar
6 ответов
+ 6
All classes are implicitly(by default) inherited from Object class so it is super class of all the classes. You can override Object class methods like toString(), toHashCode() etc in any Java class.
23rd Jul 2016, 8:58 PM
Dilip Belgumpi
Dilip Belgumpi - avatar
+ 3
To extend Eric Gitangu's answer in a simpler form: Every object in Java extends the object class. Booleans, integers, strings and even your own object classes are an object. In theory you should therefore be able to make a variable of type Object which can hold any type of objects. I know this is true in Visual Basic, but unsure in Java (Haven't tried yet). However, it is not recommended to do so, as not defining a proper object can slow down the application, or even make it crash. I hope this helped in some way, and good luck! ~ Frekvens1
24th Jul 2016, 1:11 AM
Thomas Alme
Thomas Alme - avatar
+ 2
Aptly named, everything in java is an object. It therefore makes sense that the object class is the base class from which all classes implicitly extend or derive from. Since everything is an object in java, all types are implicitly of type object and actually extend the object class.
24th Jul 2016, 12:03 AM
Eric Gitangu
Eric Gitangu - avatar
+ 2
everything is an object but not all use the object class. int long double float short byte dont use them.
24th Jul 2016, 3:39 PM
Eric Zeus
Eric Zeus - avatar
+ 1
Object class is the superclass of all the classes in java.
23rd Jul 2016, 7:38 PM
Pravin Sable
Pravin Sable - avatar
0
Yes it is
29th Jul 2016, 6:07 PM
Tribhusan kharel
Tribhusan kharel - avatar