Results 1 to 4 of 4
Thread: Creating an instance
- 11-10-2012, 04:30 AM #1
Member
- Join Date
- Nov 2012
- Location
- Johannesburg, South Africa
- Posts
- 40
- Rep Power
- 0
-
Re: Creating an instance
What do you think is the correct answer? And have you tried this?
- 11-11-2012, 05:41 AM #3
Member
- Join Date
- Nov 2012
- Location
- Johannesburg, South Africa
- Posts
- 40
- Rep Power
- 0
Re: Creating an instance
my bad, my bad! Forgive me,I was just being lazy. I just tried it, & it can't compile because Apple & Fruit are incompatible types
-
Re: Creating an instance
No, it's not because their incompatible, but rather the example has them reversed. A general type can be assigned a more specific (child) instance, but not the other way around. This is because the child retains all of the states and behaviors of the parent, and can be held by a parent variable, but again, not the other way around.
Similar Threads
-
Creating an instance variable in one class that connects to another instance variable
By SpicyElectricity in forum New To JavaReplies: 1Last Post: 04-21-2012, 06:03 PM -
Java Referencing vs creating instance
By garnaout in forum New To JavaReplies: 8Last Post: 03-16-2012, 03:12 PM -
Finding and Creating Instance of Every Class in Package
By Julian Trust in forum New To JavaReplies: 5Last Post: 06-25-2011, 08:34 AM -
Help with creating an instance of a class extension
By Inferno719 in forum New To JavaReplies: 19Last Post: 05-04-2011, 03:53 AM -
get java.lang.NullPointerException while creating an instance
By Basit56 in forum New To JavaReplies: 10Last Post: 01-06-2010, 08:33 AM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks