Kuldeep Singh
Kuldeep Singh

Reputation: 35

Can we add the more methods in Object class of java?

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

Answers (1)

T.J. Crowder
T.J. Crowder

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 class Object?

No, they'll be separate classes. Of course, calling a class Object would be confusing and surprising to people reading the code.

Upvotes: 7

Related Questions