• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Exercise Question (Yet another)

 
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)
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.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!