1. class Phone {
2. static
String device = "Phone.device";
3. void showDevice() {
4. System.out.print("Phone.showDevice," + device + " ");
5. }
6. Phone() {
7. showDevice();
8. }
9. }
1. class Mobile extends Phone {
2. String device = "Mobile.device";
3. void showDevice() {
4. System.out.print("Mobile.showDevice," + device + " ");
5. }
6. Mobile() {
7. showDevice();
8. }
9. public static void main(String[] args) {
10. Mobile n = new Mobile();
11. n.showDevice();
12. }
13. }
result of the above code is :
Mobile.showDevice,null Mobile.showDevice,Mobile.device Mobile.showDevice,Mobile.device
I coulod not understand-
The Phone costructor should call its own showDevice() method but it is calling showDevice method of Mobile class???