• Post Reply Bookmark Topic Watch Topic
  • New Topic

Exercise Question (Yet another)  RSS feed

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone

I got this exercise:

Create a private inner class that implements a public interface.
Write a method that returns a reference to an instance of the
private inner class, upcast to the interface. Show that the inner
class is completely hidden by trying to downcast to it.

I created the inner class that implements a public interface, but i just can't seem to understand the rest of it. In the method I'm writing, does he wants me to return the created object of the inner class, return the interface, or what?

And what he means by downcasting?

I think I have a problem with understanding what is the daily use of upcast and downcast, because I think I understood the meaning of it

(Correct me if I'm wrong - Upcasting is going to the base class and using it's methods and members, and downcasting is the exact opposite?)


Thanks a lot for all the help guys!
 
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ooo, go look at the Singleton example I just posted. Try to cast an instance to Singleone or Singletwo.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!