@sulekha
 your analogy ,i.e., comparing objects to primitives is not correct,
objects do not just hold data,they have some behavior as well.In Object
Oriented Programming language Objects are defined as to reflect a real
world entity. Inheritance is also a feature inspired from the real world.
So a super class can never behave as a child class, because super class
would never know which class would extend it and what extra behavior is
been added.but the opposite is true a child class inherits the behavior
from the parent and act as one if required.


On Tue, Mar 12, 2013 at 9:10 PM, manish untwal <manishuntw...@gmail.com>wrote:

> according to my understanding the super class object have limited function
> like for example
> Class - animal : methods/behavior : roam() and eat()
> and a sub class hippo : method/behavior : roam(),eat() and swim()
> so a hippo is a animal then according to the polymorphic property of java
> a reference of animal can refer to object of class hippo and animal but
> still the reference can call only the behavior of class animal i.e : animal
> A = new hippo() is legal but you can't call A.swim() because it refer to
> the animal property of class hippo ie roam and eat...not swim. and also u
> can't do this as hippo H = new animal() as this means animal should have
> all the property of hippo because it is referred by a hippo reference do
> H.swim() should not be a NULL.....reply if you get it or not.
> P.S :  I tried to explain it through an example
>
> On Tue, Mar 12, 2013 at 8:51 PM, sulekha metta <metta.sule...@gmail.com>wrote:
>
>> what ever data members,member functions present in super class are
>> applicable to subclass...subclass may contain more additional
>> features....so its obvious that size of subclass object is more than
>> superclass object...now lets take an analogy of float(4 bytes) and double(
>> 8 bytes) float can be implicitly converted into double( as float size is
>> less when compared to double) but not vice versa....then why is this not
>> applicable to superclass object and subclass object(as size of superclass
>> object is less when compared to subclass)? please tell if am wrong!
>>
>>
>> On Tue, Mar 12, 2013 at 7:37 PM, subramony mahadevan <subums...@gmail.com
>> > wrote:
>>
>>> i think its just a logical reason .... take animal as superclass bird as
>>> subclass ... since we are talking about inheritance it is " is a
>>> relationship " ie bird is a animal not vice versa hence we cannot
>>> implicitly convert to subclass
>>>
>>>
>>> On Sat, Mar 2, 2013 at 6:18 PM, sulekha metta 
>>> <metta.sule...@gmail.com>wrote:
>>>
>>>> Q) why super class object can't be  implicitly converted to subclass?
>>>> is there any specific reason?
>>>> Thanks in advance!
>>>>
>>>> --
>>>> sulekha metta
>>>> B.E computer science
>>>> osmania university
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Algorithm Geeks" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to algogeeks+unsubscr...@googlegroups.com.
>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>
>>>>
>>>>
>>>
>>>  --
>>> You received this message because you are subscribed to the Google
>>> Groups "Algorithm Geeks" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>>
>>>
>>
>>
>>
>> --
>> sulekha metta
>> B.E computer science
>> osmania university
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>
>
> --
> With regards,
> Manish kumar untwal
> Indian Institute of Information Technology
> Allahabad (2009-2013 batch)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to algogeeks+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 

Cheers,

Goutham

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to algogeeks+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to