Java Classes Question:
Download Job Interview Questions and Answers PDF
Explain why the StringBuffer and the wrapper classes defined as final?
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.
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 Interview Questions And Answers
PDF