aspose file tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Is this Assignment legal Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "Is this Assignment legal" Watch "Is this Assignment legal" New topic
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is this Assignment legal
 
Similar Threads
from Khalid Mughal review questions
var-args in main() ?
why doesnt this compile?
Anonymous Inner class
The same old Interface reference type issue