Why the StringBuffer and the wrapper classes defined as final ?

Showing Answers 1 - 2 of 2 Answers

A class can be declared final if its definition is complete and no subclasses are desired or required.they are handled in different way by jvm at runtime. so both the classes are marked as final

  Was this answer useful?  Yes

Lakshmaiah

  • Sep 15th, 2006
 

By defining a class as final we are restricting the one of the main feature of OOP ie., INHERITANCE. But JavaSoft(SUN)  has provided this restricting feature because Java Developers thought that some methods  cannot be modified by the users. Eg. for those are  the methods in String , StringBuffrer ,StringBuilder , all Wrapper classes. As String is a standard class those methods should be as they are as developed by Sun. The user can not be permitted to change the functionality of those methods. If your application needs this type of situation u can decalre your class as final.

The user can't implement the method toUppercase( ) in String class as that it can convert only some of the characters into Uppercase.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions