Can you prevent your class from being inherited and becoming
a base class for some other classes?

Answers were Sorted based on User's Feedback



Can you prevent your class from being inherited and becoming a base class for some other classes?..

Answer / guest

Yes, that?s what keyword sealed in the class definition is
for. The developer trying to derive from your class will get
a message: cannot inherit from Sealed class
WhateverBaseClassName. It?s the same concept as final class
in Java

Is This Answer Correct ?    2 Yes 1 No

Can you prevent your class from being inherited and becoming a base class for some other classes?..

Answer / srivathsan

@ guest...
the answer is not incomplete.

it is implicit. Rakesh wants to tell that the sealed
methods cannot be inherited from a class that is not
sealed, even when you inherit other members from a class
that is not decorated with the keyword sealed.

Is This Answer Correct ?    1 Yes 0 No

Can you prevent your class from being inherited and becoming a base class for some other classes?..

Answer / rakesh

We can also make the methods sealed.In that case ,the class
can inherit but the sealed methods in that class cannot

Is This Answer Correct ?    0 Yes 0 No

Can you prevent your class from being inherited and becoming a base class for some other classes?..

Answer / guest

Rakesh are u keeping us in Suspense?

u must complete the answer.

but the sealed methods in that class cannot........??????

Is This Answer Correct ?    0 Yes 0 No

Can you prevent your class from being inherited and becoming a base class for some other classes?..

Answer / pank

Make your class constructor as Private then it will restrict from being inherit as well as instantiate.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Sharp Interview Questions

What is the difference between string and string in c#?

0 Answers  


If there are 2 interface IParentInterface & IChildInterface as follows. interface IParentInterface { void InterfaceMethod(); } interface IChildInterface : IParentInterface { void InterfaceMethod(); } Both the interface contains method with same name InterfaceMethod(). How InterfaceMethod() will be handled in IChildInterface as its deriving IParentInterface

3 Answers  


What is strong name assembly?

0 Answers  


Is c# queue thread safe?

0 Answers  


What is the difference between Object and class adapters?

0 Answers   QuestPond,






How to find the current application file path while runtime?

0 Answers  


What are extension methods and where can we use them?

0 Answers  


I created a class which is inherited from interface IDisposable. Now if I use object of this class with using keyword. Then How the dispose method will get call. Does garbage collector call it or some else.

2 Answers   Sapient,


In which situation(s), the use of "Delegate" is a good idea?

0 Answers   MCN Solutions,


what is software?

4 Answers   Cadsys, Zefer,


Can delegates be used as callbacks?

0 Answers  


Explain the three services model (three-tier application). Presentation (ui), business (logic and underlying code) and data (from storage or other sources).

0 Answers  


Categories