Skip to content

Instantly share code, notes, and snippets.

@mrnirva
Created September 22, 2020 12:18
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/e65b9631889d5b66c58e54a217a537f8 to your computer and use it in GitHub Desktop.
Save mrnirva/e65b9631889d5b66c58e54a217a537f8 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.yazdir();
// Araç sınıfının özelliğini kamyon için kullanabildik
kamyon.tekerler = 5;
System.out.println(kamyon.tekerler);
}
}
class Arac{
public int tekerler;
void yazdir(){
System.out.println("Araç Sınıfı");
}
}
class Kamyon extends Arac{
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment