| Author |
Is this Assignment legal
|
priti manas duddilla
Greenhorn
Joined: Jul 17, 2007
Posts: 25
|
|
Can some one please clarify, if the assignment at line 1 is legal? Also please do tell me the o/p.
|
 |
ahmed yehia
Ranch Hand
Joined: Apr 22, 2006
Posts: 424
|
|
You would need a cast like this:
|
 |
priti manas duddilla
Greenhorn
Joined: Jul 17, 2007
Posts: 25
|
|
Ok, if i cast it, is the output "hello" ? because test class is not implementing the interface.
|
 |
ahmed yehia
Ranch Hand
Joined: Apr 22, 2006
Posts: 424
|
|
watch this code: At line 1 you are creating a polymorphic object of type test that refers to an object of type tester which implements the interface. At line 2 you are casting that object to interface so its ok. output: hello
|
 |
priti manas duddilla
Greenhorn
Joined: Jul 17, 2007
Posts: 25
|
|
Oh! My mistake. Thanks got it.
|
 |
 |
|
|
subject: Is this Assignment legal
|
|
|