Created
September 22, 2020 15:14
-
-
Save mrnirva/49323cc816203ad5060ef8a1e6430ad1 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 abstractclass; | |
public class SoyutSinif { | |
public static void main(String[] args) { | |
Baliklar balik = new Baliklar(); | |
Kuslar kus = new Kuslar(); | |
balik.yemekYe(); | |
kus.yemekYe(); | |
} | |
} | |
// Soyut Sınıf | |
abstract class Hayvanlar{ | |
// Soyut Metot | |
abstract void yemekYe(); | |
} | |
// extends ile soyut sınıf miras alınır | |
class Baliklar extends Hayvanlar{ | |
@Override | |
void yemekYe() { | |
System.out.println("Yem İle Beslen"); | |
} | |
} | |
class Kuslar extends Hayvanlar{ | |
@Override | |
void yemekYe() { | |
System.out.println("Balık İle Beslen"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment