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

What is an Abstract Class?

Câu trả lời

What is an Abstract Class?

An abstract class in C# is a special type of class that cannot be instantiated directly. It serves as a base class for other classes to inherit from and provides a blueprint for derived classes to follow. Abstract classes can contain both abstract and non-abstract (concrete) methods, as well as properties, events, and fields.

Here are the key characteristics of an abstract class in C#:

1. Cannot be instantiated directly

You cannot create an instance of an abstract class using the new keyword. Abstract classes are meant to be inherited by other classes.

2. Can contain abstract and non-abstract methods

Abstract classes can have both abstract methods (without implementation) and non-abstract methods (with implementation). Derived classes must provide an implementation for all abstract methods.

3. Can have access modifiers

Abstract classes can have access modifiers, such as public, protected, internal, or private, which determine the visibility and accessibility of the class members.

4. Can have constructors

Abstract classes can have constructors, which are called when an instance of a derived class is created.

5. Can have fields, properties, and events

Abstract classes can contain fields, properties, and events, just like regular c...

junior

junior

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

expert

What's the difference between the System.Array.CopyTo() and System.Array.Clone() ?

middle

What is scope of a Internal member variable of a C# class?

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