Inheritance
This blog will tell you about Inheritance in Hindi and English.Inheritance is a concept of OOps(Object oriented paradigm).Scroll down for Hindi translation.
Inheritance in English
The feature by which one class acquires the characteristics of an existing class is known as inheritance . In java , a class that inherits the superclass is called a subclass and the class that inherits the superclass is called a subclass. For example, the BallpointPen class is a part of the Pen class.
In terms of an OOps, this means that BallPointPen is a subclass derived from it` s superclass, Pen. The principle behind inheritance is that each derived class acquires all the characteristics of it` s superclass, thereby ensuring reusability of the code.In Java, the extends keywords are used in the subclass definition to inherit a superclass.
class Employee {
float salary=40000;
}
class Programmer extends Employee{
int bonus=10000;
public static void main(String args[]){
Programmer p=new Programmer();
System.out.println(“Programmer salary is:”+p.salary);
System.out.println(“Bonus of Programmer is:”+p.bonus);
}
}
Inheritance in Hindi
सुविधा जिसके द्वारा एक वर्ग को एक मौजूदा वर्ग की विशेषताओं का अधिग्रहण किया जाता है उसे विरासत कहा जाता है। जावा में, एक वर्ग जो सुपर क्लास को विरासत में लेता है उसे एक उपवर्ग कहा जाता है और जो वर्ग को सुपर क्लास को प्राप्त होता है उसे एक उपवर्ग कहा जाता है उदाहरण के लिए, बॉलपॉइंटपेन क्लास एथ ईपीएन क्लास का एक हिस्सा है।
ओओप्स के संदर्भ में, इसका मतलब है कि BallPointPen एक सुपर क्लास, पेन से प्राप्त उपवर्ग है। विरासत के पीछे के सिद्धांत यह है कि प्रत्येक व्युत्पन्न वर्ग अपने सुपरक्लास की सभी विशेषताओं को प्राप्त करता है, जिससे कोड की आगामी पुन: प्रयोज्यता प्राप्त होती है। जावा में, विस्तार वाले कीवर्ड का उपयोग सुपरवेलैस के अधिग्रहण के लिए उपवर्ग परिभाषा में किया जाता है।
class Employee {
float salary=40000;
}
class Programmer extends Employee{
int bonus=10000;
public static void main(String args[]){
Programmer p=new Programmer();
System.out.println(“Programmer salary is:”+p.salary);
System.out.println(“Bonus of Programmer is:”+p.bonus);
}
}
3 thoughts on “Inheritance”
siddharth
(September 13, 2017 - 6:39 am)nice
gookas
(September 13, 2017 - 5:45 pm)thanks for your appiciation 😉
Most Simple Encapsulation | Gookas
(December 7, 2017 - 8:07 am)[…] Inheritance in Hindi […]