//Output Child.public void method1() 5 Parent.public static void method2() ============= Can someone explain why is these 3 outputs are comming. I expected it to be: Child.public void method1() // Object's Class Method which is same as output 10 // ObjectReference's Class variable - output different Child.public static void method2() // ObjectReference's Class method - output different [ October 13, 2008: Message edited by: Rob Prime ]
method3() is not present in Child class so the method of PArent clas is called.
Now the method1 of child will be called since it is present there but the method2 will be called of PArent because method3 is instance of PArent and not Child. The static method is called of the instance and method3 instance is PArent