| Author |
Function Overriding
|
harmeet saini
Ranch Hand
Joined: Apr 11, 2010
Posts: 33
|
|
Hi
Following is a code from CertPal, i am not able to understand why the following code gives me a compile time error
|
Regards,
Harmeet Singh
|
 |
Abimaran Kugathasan
Ranch Hand
Joined: Nov 04, 2009
Posts: 2066
|
|
|
Why don't you get the Error with the help of the Compilation Error? What about your 10th line? Is it legal? Check it.
|
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
|
 |
Prasad Kharkar
Ranch Hand
Joined: Mar 07, 2010
Posts: 438
|
|
we cannot refer to object of super type using subclass type reference
that is why the compiler complains
|
SCJP 6 [86%] June 30th, 2010
If you find any post useful, click the "plus one" sign on the right
|
 |
Shanky Sohar
Ranch Hand
Joined: Mar 17, 2010
Posts: 1046
|
|
Brain pain = new Stain(); pain.stake();
as brain extends stain(); //////so brain ISA stain;
this line gives error as the supertype object cannot be refer from a subtype reference......
|
SCJP6.0,My blog Ranchers from Delhi
|
 |
harmeet saini
Ranch Hand
Joined: Apr 11, 2010
Posts: 33
|
|
|
Thnks to all.... jus got my doubt clear
|
 |
 |
|
|
subject: Function Overriding
|
|
|