Created
June 16, 2017 09:19
-
-
Save MericBERBER/2076e24f04d6e01d85eba3bfef3f3e4f 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
// Base Class | |
class Ust | |
{ | |
void show() { System.out.println("Üst sınıfın metodu çağırıldı."); } | |
} | |
// Inherited class | |
class Alt extends Ust | |
{ | |
// Üst sınıfın metodu override edildi. | |
void show() { System.out.println("Alt sınıfın metodu çağırıldı."); } | |
} | |
// Driver class | |
class Main | |
{ | |
public static void main(String[] args) | |
{ | |
//Ust sınıfın tipinde nesne oluşturulduğu | |
// için üst sınıfın metodu çağırılır. | |
Ust obj1 = new Ust(); | |
obj1.show(); | |
// Alt sınıfın tipinde nesne oluşturulduğu | |
// için alt sınıfın metodu çağılır. | |
Parent obj2 = new Alt(); | |
obj2.show(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment