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 encapsulation; | |
public class Kapsulleme { | |
public static void main(String[] args) { | |
Araba araba = new Araba(); | |
// Bu şekilde erişemeyiz artık | |
// araba.renk = "Mavi"; |
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 sinifnesne; | |
public class SinifNesne { | |
public static void main(String[] args) { | |
// Yapıcı metot içerisinden bir | |
// başka yapıcı metot çağırıyoruz | |
Arac araba = new Arac(); |
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 sinifnesne; | |
public class SinifNesne { | |
public static void main(String[] args) { | |
// Seçtiğimiz rengi yapıcı metoda gönderiyoruz | |
Arac araba = new Arac("Mavi"); | |
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 sinifnesne; | |
public class SinifNesne { | |
public static void main(String[] args) { | |
Arac araba = new Arac("Merhaba Dünya"); | |
// Burada parametreden veri yolladığımız için | |
// İkinci yapıcı metot çağırılacaktır |
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 sinifnesne; | |
public class SinifNesne { | |
public static void main(String[] args) { | |
/* | |
Nesne ilk oluşturulduğu an | |
yapıcı metot çağırılacaktır |
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 sinifnesne; | |
public class SinifNesne { | |
public static void main(String[] args) { | |
// Nesne oluşturmak | |
// Nesne oluşturulurken new anahtar kelimesi kullanılır | |
Arac araba = new Arac(); |
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 { | |
static final float PI = 3.14f; | |
public static void main(String[] args) { | |
// PI = 40; | |
// Bu işlem kesinlikle hata verecektir |
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; |
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(); | |
// boy'a veya sacRengine artık erişimimiz yok | |
// Çünkü ikiside private sadece Baba sınıfına aitler |
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) { | |
// Bir çocuk nesnesi oluşturduk | |
Cocuk cocuk = new Cocuk(); | |
// Buradan Baba'da olan bir özelliğe rahatlıkla eriştik |