How and when to prevent inheritance?

Questions by vidhya165   answers by vidhya165

Showing Answers 1 - 12 of 12 Answers

sbarik

  • Jan 30th, 2006
 

One can prevent inheritance by declaring a class with keyword final  .By declaring a class as final no other class can extend it..

final class Example

{

/*  

     Code   for u r application..

*/

}

subhash g.

  • Jan 30th, 2006
 

should provide the final keyword to class,because final classes are not inherited

tulasi_yl

  • Jan 30th, 2006
 

Final is Keyword which is used to prevent a class to Extend..when to stop the inheritance is up to u..when u need u'r class not to be subclassed further more then  we can prevent inheritance

  Was this answer useful?  Yes

kiran

  • Feb 3rd, 2006
 

inheritance is prevented when u are sure that your class is a child/leaf and cannot be parent of any other class.U are sure that class is already saturated with functionality and won't be much help by extending it. 

how- use keyword 'final'

  Was this answer useful?  Yes

Dhananjay Khodve

  • Mar 9th, 2006
 

Please don't put wrong comments here bcoz lots of people read these comments.

You can prevent inheritance by making a final class.

bye

Nagaraju

  • May 17th, 2006
 

if u provide

private access specifier for Constructor, in these case also it will no allow to create a subclass.

and all of us know u can use final keyword before class.

  Was this answer useful?  Yes

iyck

  • Jul 5th, 2006
 

If we make Final class we cannot extend, also if we make all the constructor private then we cannot extend that class, is this also prevents inheritence?

  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