Skip to content

Instantly share code, notes, and snippets.

@mrnirva
Created September 22, 2020 12:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrnirva/1f84dffd080a389633a6481e28916b29 to your computer and use it in GitHub Desktop.
Save mrnirva/1f84dffd080a389633a6481e28916b29 to your computer and use it in GitHub Desktop.
package inheritance;
public class Kalitim {
public static void main(String[] args) {
// Her iki sınıftanda nesne oluşturduk
Arac arac = new Arac();
Kamyon kamyon = new Kamyon();
// yazdir metodunu çağırdık
arac.yazdir();
kamyon.kamyonYazdirMetodu();
}
}
class Arac{
public Arac(){
System.out.println("Araç Sınıfı Oluştu");
}
void yazdir(){
System.out.println("Araç Sınıfı Yazdir");
}
}
class Kamyon extends Arac{
public Kamyon(){
// Bu sayede üst sınıfın yapıcı metodunu çağırdık
super();
}
void kamyonYazdirMetodu(){
// Bu sayede üst sınıfın yazdir metodunu çağrıdık
super.yazdir();
System.out.println("Kamyon Sınıfı");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment