File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Number class abstract methods... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Number class abstract methods..." Watch "Number class abstract methods..." New topic
Author

Number class abstract methods...

smita raval
Greenhorn

Joined: Aug 31, 2002
Posts: 28
In java api, for Number class, they have written as follows.
"Subclasses of Number must provide methods to convert the represented numeric value to byte, double, float, int, long, and short. "
But methods byteValue() and shortValue() are not declared 'abstract'. How it's "must" for it's subclasses ?


Smita Raval
Alfred Kemety
Ranch Hand

Joined: Aug 14, 2002
Posts: 279
If you would read further on that, you will find that they are not abstract because they actually use the intValue() provided by the subclasses and just cast the result to byte and short, so they need not be abstract. Yet if you subclass the Number class you can still override them, not implement them like intValue.
HTH
[ October 13, 2002: Message edited by: Alfred Kemety ]

Alfred Raouf - Egypt - SCJP 1.4<br />Kemety.equals(Egyptian) // returns true
smita raval
Greenhorn

Joined: Aug 31, 2002
Posts: 28
It's OK but the question is that when you can create a subclass of Number, you can create it without using those two methods. So, it should not be "must" for a subclass of Number. In java classes they have implemented, is right. But what if I create a subclass of Number and I don't want to use those two methods. I can do it without error.....
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Number class abstract methods...
 
Similar Threads
Abstract Method & Static Abstract Class, Methods
inheritance doubt
ABSTRACT
Abstract Methods
if super class is abstract, subclass must be abstract?