aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Overriding Doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Overriding Doubt" Watch "Overriding Doubt" New topic
Author

Overriding Doubt

Abhi vijay
Ranch Hand

Joined: Sep 16, 2008
Posts: 509
We cannot override non-static methods with static methods.

All the Wrapper classes extends the Number class, which in turn extends the Object class.
In the Object Class, toString() is non-static, but in the Wrapper Classes, toString() is static. How does that work?
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3775

Abhi vijay wrote:

In the Object Class, toString() is non-static, but in the Wrapper Classes, toString() is static. How does that work?


Which Wrapper classes are you talking about? Integer,Double.... ? If so you will have to refer to API for details of those. Because they do have toString() method overriden, plus static toString() (toString(double d) for Double etc...).


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3775

[Delete me please]
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9280
    
  17

Well the static toString method in the wrapper classes takes a primitive parameter while the non-static toString method of Object class doesn't take any paremeter...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Abhi vijay
Ranch Hand

Joined: Sep 16, 2008
Posts: 509
Oh yes! :-(
Sorry for asking such a stupid question.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Overriding Doubt
 
Similar Threads
Design Doubt
Strange Byte Comparision
wrapper classes
Number to String ?
toString()