Java Classes Question:

Explain why the StringBuffer and the wrapper classes defined as final?

Tweet Share WhatsApp

Answer:

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.

Download Java Classes PDF Read All 76 Java Classes Questions
Previous QuestionNext Question
Tell me is it ok to say interfaces, classes are of polymorphism(i.e we can use those for different purposes). if not then why?Methods that have a return type other than void return a value to the calling routine using the following form of the return statement:return value;

A) True
B) False