Can anybody tell me whether the Mind Q Question 34 answer given is right or wrong ?!!!
34. Assume that Sub1 and Sub2 are both subclasses of class Super.
Given the declarations:
Super super = new Super();
Sub1 sub1 = new Sub1();
Sub2 sub2 = new Sub2();
Which statement best describes the result of attempting to compile and execute the following statement:
super = sub1;
a) Compiles and definitely legal at runtime
b) Does not compile
c) Compiles and may be illegal at runtime
My answer is b, but the answer is given as a. The reason for me to select b as answer is that the line
" Super super = new Super(); " uses the key
word "super". If you change the object name "super" to anything else say "sup" it will work and the answer will be a.
Correct me if I'm wrong.
------------------