I have some confusion about the use of Factory pattern.
I understand the concept of Factory pattern. Following is my understanding.
A simple factory returns an instance of any one of several possible classes that have a common parent class.
The common parent class can be an abstract class, or an interface.
The calling program typically has a way of telling the factory what it wants, and the factory makes the decision which subclass should be returned to the calling program. It then creates an instance of that subclass, and then returns it to the calling program.
My question is as the factory class would create an instance of subclass but will always return it as a reference to super class, what will happen if sub class adds some more methods? How those methods can be called as the returned reference is of super class which doesnt have any knowledge of the methods added in sub class?