What is class and inheritance ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5

What is class and inheritance ?

what is the use of this. plz like and coment here

30th Nov 2016, 5:01 AM
Salih Ac
Salih Ac - avatar
2 Answers
+ 7
In object-oriented programming, inheritance enables new objects to take on the properties of existing objects. A class that is used as the basis for inheritance is called a superclass or base class. A class that inherits from a superclass is called a subclass or derived class. Inheritance is a good choice when: Your inheritance hierarchy represents an "is-a" relationship and not a "has-a" relationship. You can reuse code from the base classes. You need to apply the same class and methods to different data types. The class hierarchy is reasonably shallow, and other developers are not likely to add many more levels. You want to make global changes to derived classes by changing a base class.
30th Nov 2016, 5:55 AM
Akwin Lopez
Akwin Lopez - avatar
+ 2
Classes are made to organize similar functions under one umbrella. Inheritance is made to organize hierarchy among classes
10th Dec 2016, 6:15 PM
Shiv Singh Sisodiya
Shiv Singh Sisodiya - avatar