Generic references for sub class object

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Larsen
    New Member
    • May 2011
    • 2

    Generic references for sub class object

    Hi all,
    What is the advantage of having generic reference to sub class objects?

    Animal h = new Horse();
  • Dheeraj Joshi
    Recognized Expert Top Contributor
    • Jul 2009
    • 1129

    #2
    Are you talking about programing to an interface rather than implementations ?
    I am confused. Can you elaborate a little?

    Check this link

    Regards
    Dheeraj Joshi

    Comment

    • Larsen
      New Member
      • May 2011
      • 2

      #3
      Hi Dheeraj,
      Consider we have a super class A and a sub class B. What is the advantage of having super class reference type for a sub class object? Like,
      A a = new B();

      Comment

      Working...