I have three classes like below
public abstract class Parent {
public void parentCallerMethod() {
getMethod(helperMethod());
}
public abstract void getMethod(String test);
public String helperMethod() {
System.out.println("inside parent helperMethod");
return "inside parent helperMethod";
}
}
2nd class
public class Child extends Parent {
@Override
public void getMethod(String test) {
System.out.println("Inside child getMEthod....");
}
}
Final Class that calls the parent class method
public class FinalClass {
private void testMethod() {
new Child().parentCallerMethod();
}
}
My question is what does new Child().parentCallerMethod();
do? What's new Child()
. Why is that I won't be able to do Child.parentCallerMethod()
Is it similar to doing Child child = new Child();
PS : The post title may be wrong. If it's wrong I'll change it based on the answer.