Advertisement

What is Inheritance in Java in Hindi ??? Single, Multilevel ?????? Hierarchical

?????????????????? ?????????????????????, ??????????????? Java Programming ??????????????? ????????? ???????????? ?????????????????? ????????? ??????????????? ??????????????? ????????? ???????????? Class ?????? Object ?????? ???????????? ???????????? ????????? ?????? ?????? OOPs ?????? ???????????? ?????? ???????????? ?????????????????????????????? ?????????????????? (Pillar) ????????????????????? ??? Inheritance in Java in Hindi (??????????????????????????????)???

??????????????????, ????????? ???????????? ?????????????????? ?????? ????????? ?????? ?????? ?????? ????????? ??????, ?????? ???????????? ???????????? ?????? ?????? ?????? ????????? ?????????????????? ?????????????????? ?????? ??????????????? ??????? ????????????! ?????? ???????????? "??????????????????" (Inheritance) ????????? ????????? ???????????? ???????????? ?????????????????? ????????? ?????? ????????? ?????? ???????????? ????????? ????????? ???????????? ?????? ??????????????? ????????? ????????? ????????? ???????????? ??????, ?????? ?????? ??????????????? ??????????????? ????????? ????????? ?????????????????? ??????????????? ?????? ????????????, ????????? "Inherit" (????????????) ?????? ???????????? ????????????

?????? ??????????????? ????????? ?????? ????????????????????? ?????? Inheritance ???????????? ???????, extends ?????????????????? ?????? ??????????????? ???????????? ???????????? ?????? ???????????? ?????????????????? (Types) ???????????? ??????????

Advertisement

What is Inheritance in Java in Hindi? - ???????????? ????????? ?????????????????????????????? ???????????? ???????

Inheritance ?????? ????????? ??????????????????????????? ?????? ?????????????????? ?????? ??????????????? (Child Class) ??????????????? ??????????????? (Parent Class) ?????? ?????????????????????????????? (Variables) ?????? ???????????????????????? (Methods) ?????? ???????????? ???????????? ?????????

???????????????: ????????? ?????? ?????????????????? ???????????? ??????????????? ???????????? (Code Reusability) ???

Father-Son Example (?????????-???????????? ?????? ??????????????????)

  • Parent Class (Super Class): ???????????? (??????????????? ????????? ???????????? ?????? ????????? ?????????)???
  • Child Class (Sub Class): ???????????? (?????? ???????????? ?????? ????????? ???????????? ?????? + ???????????? ????????? ?????? ?????? ????????? ?????? ????????? ???????????? ??????)???

Syntax & 'extends' Keyword

?????????????????? ???????????? ?????? ????????? ?????? extends ?????????????????? ?????? ???????????????????????? ???????????? ????????????

Advertisement

class Child extends Parent {

// ?????? Child ?????? ????????? Parent ?????? ?????? ????????? ??? ?????????

}

Types of Inheritance in Java in Hindi - ???????????? ????????? ?????????????????????????????? ?????? ??????????????????

Java ????????? ??????????????? ????????? ?????? 3 ????????? ?????? ?????????????????????????????? ???????????????????????? ?????????:

1. Single Inheritance

?????? ?????? ???????????? ????????? ?????? ??????????????? ??????????????? ?????? ??????????????? ???????????? ?????? ?????? ?????? ??????????????? ?????????????????????????????? ?????????????????? ?????????

(Class B extends Class A)

2. Multilevel Inheritance

???????????? ?????? -> ???????????? ?????? -> ???????????????

(Class C extends Class B, Class B extends Class A)

???????????? ???????????? (C) ?????? ???????????? (B) ?????? ???????????? (A) ??????????????? ?????? ????????? ??????????????? ????????????

3. Hierarchical Inheritance

?????? ???????????? ?????? ?????? ?????? ?????? ?????????????????? ???????????? ???????????? ?????? ?????? ????????? Hierarchical Inheritance ????????? ???????????? ?????????

(Class B extends Class A, Class C extends Class A)

???????????? ?????? ?????? Parent Class ?????? ?????? Child Classes ?????????????????? ????????????

(?????????: Java ????????? Multiple Inheritance (?????? ???????????? ?????? ?????? ????????????) ????????????????????? ?????? ??????????????? ?????????????????? ???????????? ??????????????? ????????? ?????? Interface ?????? ??????????????? ???????????? ????????????)

Java Inheritance Code Example

???????????? Single Inheritance ?????? ?????? ???????????? ?????????????????? ??????????????? ????????????

// Parent Class

class Animal {

void eat() {

System.out.println("This animal eats food.");

}

}

// Child Class

class Dog extends Animal {

void bark() {

System.out.println("The dog barks.");

}

}

// Main Class

public class Main {

public static void main(String[] args) {

Dog d = new Dog();

d.bark(); // Child method

d.eat(); // Parent method

}

}

Output:

The dog barks.

This animal eats food.

Conclusion ??? ????????????????????????

???????????? ?????????????????? ?????? ?????? ?????? ??????????????? ?????? ???????????? Inheritance in Java in Hindi ?????? ??????????????? ?????? ????????? ???????????? ???????????????

????????? ????????????: ?????? ?????? ???????????? ????????? ?????? ?????? ????????????????????? ????????? "Is-A" ?????????????????? ?????? (???????????? Dog is an Animal), ?????? ???????????? Inheritance ????????? ???????????????

???????????? ??????????????? ????????? ?????? OOPs ?????? ??????????????? ???????????? "Polymorphism in Java" ?????????????????????, ??????????????? ???????????? ?????? "?????? ?????????, ???????????? ?????????"???

FAQs

Q1. Java ????????? Multiple Inheritance ??????????????? ???????????? ?????????????

Ans: ????????????????????? ????????? ?????? Parents ?????? ????????? ????????? ????????? ?????? ???????????? ??????, ?????? Child ????????????????????? ?????? ?????????????????? ?????? ??????????????? ???????????? ????????? ???????????? (????????? Diamond Problem ???????????? ?????????)???

Q2. Super Class ?????? Sub Class ???????????? ???????

Ans: ??????????????? ??????????????????????????? ?????? ?????? ????????? ?????? ?????? Super (Parent) ??????, ?????? ?????? ?????? ????????? ?????? ?????? Sub (Child) ?????????

Q3. ???????????? ?????? Private members ?????? inherit ?????? ???????????? ??????????

Ans: ????????????, Parent class ?????? ???????????????????????? ??????????????? ?????? Child class ?????????????????? ???????????? ?????? ???????????????

Table of Contents

Close

Share to other apps

Report Content

Why are you reporting this content?

Your selection helps us review the content and take appropriate action.

Hate & Discrimination
Content that spreads hate or unfair treatment against a person or group because of who they are.
Abuse & Harassment
Content that insults, threatens, bullies, or makes someone uncomfortable.
Violence & Threats
Content that talks about hurting people, animals, or property, or supports violence.
Child Safety
Any content that harms, exploits, or puts children at risk.
Privacy Violation
Sharing someone’s personal information or photos without permission.
Illegal & Regulated Activities
Content that promotes or helps with illegal activities like drugs, weapons, or trafficking.
Spam & Misleading Content
Fake, misleading, or repeated content meant to trick users.
Suicide or Self-Harm
Content that encourages or explains self-harm or suicide.
Sensitive or Disturbing Content
Shocking or graphic content that may upset users.
Impersonation
Pretending to be another person or organization.
Extremism & Hate Groups
Content that supports violent groups or hateful ideas.
Civic Integrity
Content that spreads false information about elections or public processes.