Skip to content

Instantly share code, notes, and snippets.

@mrnirva
Created September 5, 2020 23:15
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/f824de3a592d03b953c1d6c35cbad4dc to your computer and use it in GitHub Desktop.
Save mrnirva/f824de3a592d03b953c1d6c35cbad4dc to your computer and use it in GitHub Desktop.
package accessmodifiers;
public class ErisimBelirleyiciler {
public static void main(String[] args) {
// Bir çocuk nesnesi oluşturduk
Cocuk cocuk = new Cocuk();
// Buradan Baba'da olan bir özelliğe rahatlıkla eriştik
cocuk.boy = 180;
// Değer atadığımız özelliği yazdırdık
System.out.println("Çocuk Boyu: "+cocuk.boy);
// Aynı şekilde babadan alıp değiştirdiğimiz metoduda çağırabildik
cocuk.dil();
}
}
// Baba isimli sınıfımız
class Baba{
protected int boy;
protected String sacRengi;
protected void dil(){
System.out.println("Türkçe");
}
}
// Babadan miras alan Cocuk sınıfımız
class Cocuk extends Baba{
@Override
protected void dil() {
System.out.println("İngilizce");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment