Skip to content

Instantly share code, notes, and snippets.

@mrnirva
Created September 5, 2020 23:50
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/9c0b5bfc7ab23d5f6be7881715158469 to your computer and use it in GitHub Desktop.
Save mrnirva/9c0b5bfc7ab23d5f6be7881715158469 to your computer and use it in GitHub Desktop.
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