Created
September 5, 2020 23:50
-
-
Save mrnirva/9c0b5bfc7ab23d5f6be7881715158469 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 accessmodifiers; | |
public class ErisimBelirleyiciler { | |
public static void main(String[] args) { | |
Cocuk cocuk = new Cocuk(); | |
// Oluşturduğumuz nesnedende erişebildik | |
cocuk.boy = 180; | |
System.out.println("Çocuk Boyu: "+cocuk.boy); | |
// Görüldüğü gibi aynı paket içerisindeyiz ve erişebildik | |
Baba.sacRengi = "Yeşil"; | |
} | |
} | |
class Baba{ | |
// Bu özellikleri default olarak güncelledik | |
// Ayrıca sacRengine static nitelemesi verdik | |
// static nitelemsini mainden erişildiğini göstermek için verdim | |
int boy; | |
static String sacRengi; | |
// Metoduda default olarak güncelledik | |
void dil(){ | |
System.out.println("Türkçe"); | |
// Boy'a buradan erişebiliriz | |
boy = 190; | |
// sacRengi'ne buradan erişebiliriz | |
sacRengi = "Kahverengi"; | |
// Sınıf içerisinden erişebildik | |
} | |
} | |
class Cocuk extends Baba{ | |
// Alt sınıftan metoda erişebildik | |
@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