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


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "final class" Watch "final class" New topic
Author

final class

kiran kumar
Greenhorn

Joined: May 24, 2008
Posts: 18
Hi,
A final class can be overloaded? Is String and StringBuffer are final classes?


Thanks & Regards,<br />Bhuvan Samrat.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

you cannot override final class(final class cannt subclasses)


String:you cannt override its method ..since String is a final class but StingBuffer is not a final class
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


A final class can be overloaded


You can't overload classes. You can overload methods. Overloading is where you provide more than one method with the same name an return type, but different parameters. e.g. :


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
camilo lopes
Ranch Hand

Joined: Aug 08, 2007
Posts: 202
one final class can't be extends.

Is String and StringBuffer are final classes?


yes.


Brazil - Sun Certified Java Programmer - SCJP 5
http://www.camilolopes.com/ About Java - Update every Week.
Guide SCJP - tips that you need know http://blog.camilolopes.com.br/livrosrevistaspalestras/
Barney Middleton
Greenhorn

Joined: Apr 08, 2008
Posts: 2
How do you know you cant over-ride it?
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Hi Barney,

Welcome to JavaRanch!

What does "it" mean in your question: final classes in general, or String, or String's methods? The rule is that you can't create a subclass of a final class at all; therefore if you can't create a subclass, there's no way to override the methods of a final class, right?


[Jess in Action][AskingGoodQuestions]
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14117
    
  16

Originally posted by rahul dravid:
A final class can be overloaded? Is String and StringBuffer are final classes?

Classes can not be overloaded, and the final keyword does not have anything to do with overloading.

Final classes cannot be subclassed.

In the API documentation you can see that classes java.lang.String and java.lang.StringBuffer are both final.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
Consider Paul's rocket mass heater.
 
subject: final class