but i am expecting the output as Mobile.showDevice,Mobile.device Mobile.showDevice,Mobile.device Mobile.showDevice,Mobile.device (bcas first it will inializes the instance variables then the constructor will run)
in the code u have, after the line Mobile n =new Mobile(); the control goes to super class constructor ,and there when u call showDevice, concept of shadowing takes place i.e it refers to sub class showDevice() method,at this time the var device is not initialized still,hence null. and the rest ouput as the flow.
if u put static modifier to the String device u wont get null,but Mobile Device try out. hope I am right