• Post Reply Bookmark Topic Watch Topic
  • New Topic

Exercise Question  RSS feed

 
Hector Zoltan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got this exercise:

Create an interface with at least one method, in its own package.
Create a class in a separate package. Add a protected inner class
that implements the interface. In a third package, inherit from
your class and, inside a method, return an object of the protected
inner class, upcasting to the interface during the return.

Now, I did everything as told, but I just can't seem to understand what it means by saying - "upcasting to the interface during the return"

What exactly does it wants me to do? I returned the inner class object as requested - is there anything more I need to do?

Thanks everyone
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It means that the method that returns the object should not be declared to have a return type of the protected inner class, but rather have the interface as its return type.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!