Câu hỏi phỏng vấn C#
Câu hỏi

What is sealed Class in C#?

Câu trả lời

A sealed class in C# is a class that cannot be inherited from or derived by other classes. It is marked with the sealed keyword and prevents further inheritance[1][2][3][4].

The main purposes of sealed classes are:

  1. To restrict inheritance and prevent other classes from deriving from it[1][2][3][4]. This can help prevent security issues by not allowing methods in the sealed class to be overridden and manipulated by other classes[3].

  2. Sealed classes are often used for classes with static members, such as the Pens and Brushes classes in the System.Drawing namespace. These classes represent standard colors and have only static members[1][3].

  3. When overriding virtual methods, you can seal them by using the sealed keyword. This allows derived classes to inherit from the class but prevents them from overriding those speci...

middle

middle

Gợi ý câu hỏi phỏng vấn

junior

Can multiple catch blocks be executed?

senior

Explain what is Short-Circuit Evaluation in C#

senior

When to use ArrayList over array[] in C#?

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào