aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Isn't final not allow overload? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Isn Watch "Isn New topic
Author

Isn't final not allow overload?

Daisy Kent
Greenhorn

Joined: Nov 22, 2002
Posts: 2
package client;
import server.ServerNames;
class Retrieve extends ServerNames
{
public final int MAXCONECTIONS=MAXUSERS*10;
public static String sendName(String s)
{ return s; }
}

package server;
public class ServerNames
{
protected final int MAXUSERS=20;
public final static String sendName()
{
return "Main Server";
}
}

When run the file
it's fine
public static String sendName(String s) why?
Ron Newman
Ranch Hand

Joined: Jun 06, 2002
Posts: 1056
It's illegal to hide a static final method, but you're not hiding it. You're overloading, which is perfectly OK.


Ron Newman - SCJP 1.2 (100%, 7 August 2002)
James Chegwidden
Author
Ranch Hand

Joined: Oct 06, 2002
Posts: 201
final methods can be overloaded, but not overridden. I had to show this once to my Java students


Author and Instructor, my book
Kathy Sierra
Cowgirl and Author
Ranch Hand

Joined: Oct 10, 2002
Posts: 1572
Howdy, you might find it easier to remember all the ins and outs of overload vs. override if you think of an overloaded method as just a *completely* different method that just *happens* to have the same name as another one.
So overloaded methods don't have to follow ANY of the overriding rules -- overloaded methods can throw new checked exceptions, they can have more restrictive access, and they can go crazy when it comes to return types. As long as that argument list is different, you're free to do whatever else you want because it is a totally new and different method.
Be watching for overloaded versions of methods from Object -- try to picture the ways in which you could *think* you are overriding, say, equals() or hashcode(), but in fact you are only overloading it. Keep a sharp eye out for things like that on the exam.
Cheers,
Kathy
author, "Shroedinger's Object"
(not in bookstores, however, because we opened the box and, well, it didn't go as we'd hoped)


Co-Author of <a href="http://www.amazon.com/exec/obidos/ASIN/0596007124/ref=jranch-20" target="_blank" rel="nofollow">"Head First Design Patterns"</a><br /> <br />Just a Jini girl living in a J2EE world.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Isn't final not allow overload?