Last active
December 2, 2019 15:53
-
-
Save AnujJha-stack/2570c11fd3f8498567c90fe0f1c81407 to your computer and use it in GitHub Desktop.
Java_Interface
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//fields are implicitly : public & static & final. | |
//methods are implicitly : public & abstract. | |
//since fields are abstract interface doesn't support constructor. | |
//>>class C2 extends C1 implements I3<< | |
//Above syntax also possible. | |
interface I1{ | |
void f1(); | |
} | |
interface I2{ | |
void f2(); | |
} | |
interface I3 extends I1,I2{ | |
void f3(); | |
} | |
abstract class C1 implements I3{ | |
abstract void f4(); | |
} | |
class C2 extends C1{ | |
public void f5(){ | |
System.out.println("From C2"); | |
} | |
public void f1(){ | |
System.out.println("From I1"); | |
} | |
public void f2(){ | |
System.out.println("From I2"); | |
} | |
public void f3(){ | |
System.out.println("From I3"); | |
} | |
public void f4(){ | |
System.out.println("From C1"); | |
} | |
} | |
class Interface{ | |
public static void main(String[] a){ | |
C2 obj = new C2(); | |
obj.f1(); | |
obj.f2(); | |
obj.f3(); | |
obj.f4(); | |
obj.f5(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment