Here is some example code of what I'm goofing up on all the time:
What will be the effect of compiling and running this class
Test?
Generates a Compiler error on the statement v= c
Generates runtime error on the statement v= c
Prints out:
A. Does not complie becasue the v=c assignment.
B. Generate a runtime error.
C. Prints out:
Vehicle : drive
Car : drive
Car : drive
D. Prints out:
Vehicle : drive
Car : drive
Vehicle : drive
The answer is 'C' and I put 'A'
I'm thinking the reference variable of type 'c' cannot be
assigned to a reference variable of type 'v', because 'v'
is a parent type and doesn't maybe have all the code/guts
of the sub type 'c'.
How can I get this right in my mind. I know a object doesn't forget
its type....
[HENRY: Added code tags and formatted code]
[ November 21, 2006: Message edited by: Henry Wong ]