About Question enthuware.ocpjp.v8.2.1788 :
Posted: Mon May 30, 2016 12:03 pm
If the return type is Interface, then how can we create an object directly or straight out of an Interface by using new Interface_Name() as inFurther, the return type of a create method is usually an interface and not a class.
return new Student("000", "Unnamed");
in your 2nd answer option?
I'm not disputing the return type being an Interface. For example, Paths factory class give us a Path Interface as its return value.
If you had, say
Code: Select all
Student aha = new Student(){
// Do useful stuff here. This would be an anonymous inner class style of coding and Student can be EITHER an abstract class OR Interface.
}
return aha;
Hope we are on the same page on this.
Thank you.
Schmichael