Skip to content

Instantly share code, notes, and snippets.

@mrnirva
Created September 22, 2020 15:14
Show Gist options
  • Save mrnirva/49323cc816203ad5060ef8a1e6430ad1 to your computer and use it in GitHub Desktop.
Save mrnirva/49323cc816203ad5060ef8a1e6430ad1 to your computer and use it in GitHub Desktop.
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