How to call getStockQuotes

How should i call getStockQuotes and getComparator inside calculateAnnualizedReturn using the interface object as the interface does not have the method signatures.

Hi @vishalbihani2
Looks like you are facing challenges in the current module.

Below is a link to all the FAQ’s for the current module

Below are a few similar topics raised by other users which you might find usefull

Note - This is a BETA Feature,if you find this helpful, kindly let us know.
Feedback link -

Kindly mark this as a solution if this has helped you solve your query

  • is the interface
  • Go to and complete the TODO, looking at the return type, you can think and decide how you can connect PortfolioManagerImpl with this.
  • Now come to, this is the one which implements PortfolioManger interface.
    And inside calculateAnnualizedReturn in you can easily make use of those functions you mentioned without any problems as they are defined in the same file.

You faced this problem as you tried to call getStockQuote & getComparator functions something like this —> portfolioManager.getStockQuote… where portfolioManager is the object you created. But this is not required here. you can call getStockQuote directly

And one more thing to note here is that, you are calling the constructor protected PortfolioManagerImpl(RestTemplate restTemplate) inside calculateAnnualizedReturn within You need not use that here. To do it the right way, please go to and follow the TODO, I think you will easily get a hint about what has to be done.

(In this module, we mainly want you to understand the usage of Factory Pattern. So go through all the files given in portfolio directory)

what i am understanding is

  1. PortfolioManager is the manager.
  2. PortfolioManagerImpl is the concrete class
  3. PortfolioManagerFactory is the factory class.

factory class will call the concrete class. am i right?

do we need to add the functions getStockQuote and getComparator in the interface? because the portfolioManagerFactory is returning the instance of the portfolioManager and i cannot call the function which is not inside the interface definition.

Hi Vishal,

you can add the getStockQuote method in PortfolioManagerImpl

what i was asking that do i need to add the getStockQuote in the interface (i.e PortfolioManager). Because it is already present in the function portfolioManagerImpl which implements it. But i cant call the function as it is not present in the interface.

@vishalbihani2 you don’t have to call the function from any other class, there’s no need to add it in the interface too, You only have to call the annualized Returns function that is present, the other functions which are available in the file can be called through this function.
To understand the flow of this particular module and how you have to code, refer to the return type of each function, whatever you have done in module 3, is being separated here into different functionalities

Can someone look at my code. I am very confused and stuck for 3 days on the same line.

Hi Vishal, you have made a really good progress since the question was asked, according to me :smile:

And now , I don’t think your doubt is related to your original question on this thread, ie calling getstockquotes. you have solved it. Earlier the way you were using it wasn’t proper. You had doubts about using the concept of factory pattern, so I would tell that you are at a better position than before…what do you say :slightly_smiling_face:??

You can create a new thread with the issue you are currently facing. Otherwise I’ve already DMed you regarding this. We can continue our discussion over there.

Thanks i think its partially resolved and i will try to do the rest

You can close the thread now thanks.

Closing this topic as it has been solved by you yourself. Great job, keep working hard. if its not resolved feel free to un-mark the accepted solution to re-open the topic.

Closing this topic as your issue has been resolved by the community. If not Kindly un-mark the accepted solution to re-open the topic or feel free to create a new topic and post a link to this topic as a reference.