Reputation: 35
We all know that Object
class is the super class in Java. Can we add methods into the Object
class?
And, if we make a new class with the name Object
then will the functionality of that class affect the super class Object
?
Upvotes: 0
Views: 87
Reputation: 1074248
Can we add methods into the
Object
class?
No. You can subclass it, but you cannot modify it (without modifying the JDK's and JRE's runtime jars; which is a Bad Idea™).
And, if we make a new class with the name
Object
then will the functionality of that class affect the super classObject
?
No, they'll be separate classes. Of course, calling a class Object
would be confusing and surprising to people reading the code.
Upvotes: 7