सीधे मुख्य सामग्री पर जाएं

#55 What is Multiple Inheritance in Java | Java में Multiple Inheritance का use कैसे करे

package com.sudhirtheindian2.java123;

//class A{
// void show(){
// System.out.println("this is class A");
// }
//
//}
//class B{
// void show(){
// System.out.println("this is class B");
// }
//}

interface A{
void show(); // public+abstract
}
interface B{
void display(); // public+abstract
}





public class Multiple implements A,B {
public void show(){
System.out.println("this is interface of a and b");
}

public void display(){
System.out.println("this is display");
}
public static void main(String[] args) {
Multiple m1 = new Multiple();
m1.show();
m1.display();


}



// Multiple inheritance in java ?
// Multiple inheritance using interface

// we can achieve multiple inheritance through interface
// because interface contains only abstract method
// which implementation is provided by the sub classes


// interface contains only abstract method


// example--->>>

// class C extends A,B; wrong
//
// class C implements A,B right




}



टिप्पणियाँ

इस ब्लॉग से लोकप्रिय पोस्ट