Last active
June 16, 2017 10:02
Star
You must be signed in to star a gist
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
class Outer { | |
private String msg = "Outer private mesaj"; | |
private void fun() { | |
System.out.println("Outer fun() metodu çağırıldı."); | |
} | |
class Inner extends Outer { | |
private void fun() { | |
System.out.println("Outer'ın private üyesine erişim : " + msg); | |
} | |
} | |
public static void main(String args[]) { | |
Outer o = new Outer(); | |
Inner i = o.new Inner(); | |
// Bu metod Inner sınıfın metodunu çağırdı. | |
// Outer'ın private member'i Inner tarafınca erişilebilir. | |
i.fun(); | |
// o.fun() Outer'ın metodunu çağırdı. ( Run Time Polymorphism gerçekleşmedi) | |
o = i; | |
o.fun(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment