Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Derived Classes | OOP Essentials
course content

Зміст курсу

C# Beyond Basics

Derived ClassesDerived Classes

When we say a class is derived from another class, it means that it has all the fields and methods of the parent class and in addition to it, the derived class can contain additional fields and methods as well.

A derived class (also called a child class) is a class which inherits the properties of some other class while on the contrary, a base class (also called a parent class) is a class which is inherited from.

The syntax for making an inherited class is the following:

cs

index.cs

Here's an example with some concrete code:

cs

index.cs

In this example, Dog is the derived class, inheriting from the Animal base class. The Dog class has access to the Name property and the Eat method from the Animal class. Additionally, it introduces a new method, Bark, which is specific to the Dog class.

As illustrated in the diagram, there can be cases where a class inherits from a class which is already a class from some other:

cs

index.cs

In such a case, the class at the top-most level is called the Super Class. In this case Animal is the super class. Such a case where where there are multiple levels of inheritence is called Multi-Level Inheritence.

In some languages it allows a class to inherit from multiple base classes, such an inheritance is called Multiple Inheritance. In C#, a class can have only one parent class so Multiple Inheritance is not possible in C#.
1. In C#, which keyword or symbol is used to declare a derived class?
2. In Multi-Level inheritance, what is the class at the top called?
3. Is Multilevel inheritance possible in C#?

In C#, which keyword or symbol is used to declare a derived class?

Виберіть правильну відповідь

In Multi-Level inheritance, what is the class at the top called?

Виберіть правильну відповідь

Is Multilevel inheritance possible in C#?

Виберіть правильну відповідь

Все було зрозуміло?

Секція 4. Розділ 1
course content

Зміст курсу

C# Beyond Basics

Derived ClassesDerived Classes

When we say a class is derived from another class, it means that it has all the fields and methods of the parent class and in addition to it, the derived class can contain additional fields and methods as well.

A derived class (also called a child class) is a class which inherits the properties of some other class while on the contrary, a base class (also called a parent class) is a class which is inherited from.

The syntax for making an inherited class is the following:

cs

index.cs

Here's an example with some concrete code:

cs

index.cs

In this example, Dog is the derived class, inheriting from the Animal base class. The Dog class has access to the Name property and the Eat method from the Animal class. Additionally, it introduces a new method, Bark, which is specific to the Dog class.

As illustrated in the diagram, there can be cases where a class inherits from a class which is already a class from some other:

cs

index.cs

In such a case, the class at the top-most level is called the Super Class. In this case Animal is the super class. Such a case where where there are multiple levels of inheritence is called Multi-Level Inheritence.

In some languages it allows a class to inherit from multiple base classes, such an inheritance is called Multiple Inheritance. In C#, a class can have only one parent class so Multiple Inheritance is not possible in C#.
1. In C#, which keyword or symbol is used to declare a derived class?
2. In Multi-Level inheritance, what is the class at the top called?
3. Is Multilevel inheritance possible in C#?

In C#, which keyword or symbol is used to declare a derived class?

Виберіть правильну відповідь

In Multi-Level inheritance, what is the class at the top called?

Виберіть правильну відповідь

Is Multilevel inheritance possible in C#?

Виберіть правильну відповідь

Все було зрозуміло?

Секція 4. Розділ 1
some-alt