Last active
September 22, 2020 15:58
-
-
Save mrnirva/0fdd21eaa050b2a081d797315059b231 to your computer and use it in GitHub Desktop.
This file contains 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
package interfaces; | |
public class Arayuzler { | |
public static void main(String[] args) { | |
Kopekler kopek = new Kopekler(); | |
Koyunlar koyun = new Koyunlar(); | |
kopek.yemekYe(); | |
koyun.yemekYe(); | |
} | |
} | |
// Arayüz tanımlarken interface ile belirlenir | |
// Daha sonra arayüze bir isim verilir | |
interface Hayvanlar{ | |
// Gövdesiz metot yazılır | |
void yemekYe(); | |
} | |
// implements kelimesi ile miras alınır | |
class Kopekler implements Hayvanlar{ | |
// Metot içeride ezilerek yeniden yazılır | |
@Override | |
public void yemekYe() { | |
System.out.println("Et Ye"); | |
} | |
} | |
class Koyunlar implements Hayvanlar{ | |
@Override | |
public void yemekYe() { | |
System.out.println("Ot Ye"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment