Wats the diff between sealed class and private class in
inheritance

Answer Posted / vishal

Sealed Class:
When applied to a class, the sealed modifier prevents other
classes from inheriting from it. In the following example,
class B inherits from class A, but no class can inherit
from class B.

class A {}
sealed class B : A {}

You can also use the sealed modifier on a method or
property that overrides a virtual method or property in a
base class. This enables you to allow classes to derive
from your class and prevent them from overriding specific
virtual methods or properties.


Private Class :

Classes and structs that are not nested within other
classes or structs can be either public or internal. A type
declared as public is accessible by any other type. A type
declared as internal is only accessible by types within the
same assembly. Classes and structs are declared as internal
by default unless the keyword public is added to the class
definition. And yes, a class cannot be private unless of
course if it a nested class.

Is This Answer Correct ?    29 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is concrete class in c#?

476


What does the parsefloat function do?

493


What is the difference between constant and readonly in c#?

435


What is deferred execution?

481


Explain the clr triggers?

526






Is it possible to have different access modifiers on the get/set methods of a property?

519


What is different between Implicit conversion and Explicit conversion in C#?

518


What is a clr host?

557


Ho we can see assembly information?

521


What do you mean by saying a "struct is a value type"?

522


What is a constructor in c#?

518


What is an assembly qualified name

524


What are the new features in c# 2.0?

517


Explain what a diffgram, and a good use for one Define diffgram? How it be used?

549


Give an example of a directcast.

518