Why would I want to make a class final? Doesn't that defeat the whole purpose of OO?

Questions by krishna_darl   answers by krishna_darl

Showing Answers 1 - 4 of 4 Answers

pvnarasimhareddy

  • Jun 15th, 2006
 

 if u wanna class that should not be extened we can use final class.no is not draw back of oo but is nothing but encapsulation that is going to hide information.

           if i am wrong please inform me

  Was this answer useful?  Yes

Neha

  • Dec 20th, 2006
 

to add to above:String class is also final

  Was this answer useful?  Yes

Deepak Sharma

  • Dec 21st, 2006
 

exactly, it  is used only for encapsulation for hiding the information.

eg.. string class is also defined as final..if u want to see more than see the rt.jar in which all the classes are defined in jdk141_05jrelibrt.jar.

thanx and regards

Deepak Sharma

  Was this answer useful?  Yes

pdommara

  • Oct 6th, 2010
 

If you are sure on that behaiour  of your class and sure that no one from outside world should not change the its behaviour, then you can make the class as final. Thats why java have String class as final why bcas java authors dont want to change its bahaviour.

  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.