which one is called? what is the output? why? what is the difference? (Q2 is more important for me)
imagine these classes: class Parent{ public void f(){ System.out.println("f() in Parent"); } } //-------------------------------------------------------------- class Child extends Parent{ public void f(){ System.out.println("f() in Child"); } } //-------------------------------------------------------------- public class SomeClass { public void method(Parent p){ System.out.println("method(Parent)"); } public void method(Child p){ System.out.println("method(Child)"); } } //-------------------------------------------------------------- Now I have 2 Questions: Q1: Parent obj1 = new Child(); obj1.f(); Q2: SomeClass obj2 = new SomeClass(); Parent obj3 = new Child(); obj2.method(obj3);