+ 1

Inheritance

What is max number of class can inherit from sealed or final class? Please tell me : " class can inherit from sealed class" or "can be inherited from sealed class"? I little bit confusing every time I encounter this question:)

15th Jun 2024, 7:38 AM
Oliver Pasaribu
5 odpowiedzi
+ 2
A sealed class is from C#, and you cannot inherit from a sealed class.
15th Jun 2024, 10:26 AM
Jan
Jan - avatar
+ 2
You seem to be stuck on English grammar. But focus on this expression (in your original question): "inherit FROM a sealed or final class" Because of "from", the sealed or final class is the PARENT. And inheritance is not allowed with these keywords. If you think about people. When an old man dies, his family can inherit his wealth. Similarly, in OOP a child class can inherit from a parent class all of its fields and methods.
18th Jun 2024, 5:57 AM
Tibor Santa
Tibor Santa - avatar
+ 1
Please tag what language do you mean.
15th Jun 2024, 8:16 AM
JaScript
JaScript - avatar
+ 1
So, i guess Two possibilities here: 1. We are creatingba base class which is defined as sealed baseClass, and this is questioning about how many derived class can be inherited from sealed baseClass? The answer is none. Sealed dissallow a class to be inherited. 2. We are creating an ordinary class namely baseClass, and it is questioning: how many new sealed-derived classes can be inherited from this baseClass: the answer is infinite number.
17th Jun 2024, 5:04 AM
Oliver Pasaribu
0
The correct one (please choose): * What is the maximum number of classes can inherit from a sealed class? Or: * What is the maximum number of classes can be inherited from a sealed class? Confusing:) I still in b2 cfer:) please explain, since many undergraduate textbooks using "can be inherited from..." instead of "can inherit from...":)
15th Jun 2024, 10:48 AM
Oliver Pasaribu