Can you prevent a class from overriding?

Answers were Sorted based on User's Feedback



Can you prevent a class from overriding?..

Answer / techy_unknown

Hi,

I think the question itself is illogical.

The term "overriding" is ONLY and ONLY associated with
methods/properties not to the class.

So, if the question is put a like, "How to prevent methods
not to be overriden?" then the answer is: "Make them non-
virtual."

And if the question is put a like, "How to prevent the
inheritance for a specific class?" then the answer
is, "Make the calss sealed."

I really hope that the reply makes sense here.

Is This Answer Correct ?    38 Yes 1 No

Can you prevent a class from overriding?..

Answer / aa

make the class sealed

Is This Answer Correct ?    6 Yes 7 No

Can you prevent a class from overriding?..

Answer / nazrul

we can use sealed keyword at the time of declartion of class
thorugh which it won't inherit and won't be overide.

Is This Answer Correct ?    4 Yes 6 No

Post New Answer

More C Sharp Interview Questions

What does exclamation mark mean in access query?

0 Answers  


What happens if you add duplicate elements to a set?

0 Answers  


What is the use of list in c#?

0 Answers  


What is difference between array and arraylist c#?

0 Answers  


Hello.. This is kali prasad. i wish to learn C#. kindly guide me in making me expert in c#.

2 Answers  






How many types of methods are there in c#?

0 Answers  


Why do we use stringbuilder in c#?

0 Answers  


How many bits is int32?

0 Answers  


What is variable in c#?

0 Answers  


how to handle errors in sqlserver

1 Answers  


how to access the virtual method without creating the objet for the virtual method?

1 Answers  


What is anonymous method in c#?

0 Answers  


Categories