does java support multiple inheritances


does java support multiple inheritances क्या जावा मै multiple inheritances support होता है

does java support multiple inheritances


does java support multiple inheritances क्या जावा मै multiple inheritances support होता है हम जानेगे multiple inheritances क्या होता है ? जावा मै multiple inheritances को क्यों इस्तमाल करते है क्या जावा multiple inheritances को support करता है या नहीं ?

what is multiple inheritances ?

Multiple inheritance is a feature that allows a class to inherit properties and behaviors from more than one parent class simultaneously..

what is multiple inheritances in java ?

Multiple inheritance is not directly supported in Java, but you can achieve similar functionality by implementing multiple interfaces..

java मै multiple inheritances को achieve कैसे किया जाता है ?

जावा मै multiple inheritance, where a class directly inherits from multiple classes, is not supported. However, you can achieve similar functionality through the following approaches:

Implementing Multiple Interfaces: Java allows a class to implement multiple interfaces. By implementing multiple interfaces, a class can inherit and provide the behavior defined by those interfaces, effectively achieving a form of multiple inheritance through interface inheritance...

आएये हम example के माध्यम से जानते है -

interface InterfaceA 

{

    void methodA();

}

 

interface InterfaceB 

{

    void methodB();

}

 

class MyClass implements InterfaceA, InterfaceB 

{

    public void methodA() 

{

        // Implementation for method A

    }

   

    public void methodB() {

        // Implementation for method B

    }

}

Using Composition: Instead of inheriting from multiple classes, you can use composition to combine the functionalities of multiple classes. This involves creating an object of one class within another class and utilizing its behavior...

आएये हम example के माध्यम से जानते है -

class ClassA 

{

    public void methodA() 

{

        // Implementation for method A

    }

}

 

class ClassB 

{

    public void methodB() 

{

        // Implementation for method B

    }

}

 

class MyClass

 {

    private ClassA classA;

    private ClassB classB;

   

    public MyClass() 

{

        classA = new ClassA();

        classB = new ClassB();

    }

   

    public void methodA() 

{

        classA.methodA();

    }

   

    public void methodB() 

{

        classB.methodB();

    }

}

निष्कर्ष :-

does java support multiple inheritances ?

No, Java does not support multiple inheritances in the context of directly inheriting from multiple classes. Java supports single inheritance, where a class can only inherit from a single parent class. However, Java does support implementing multiple interfaces, which provides a form of multiple inheritance through interface inheritance....

और पढ़े

resultset types in java

Heap and Stack Memory in Java


एक टिप्पणी भेजें

0 टिप्पणियाँ