aspose file tools*
The moose likes Beginning Java and the fly likes Casting Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Casting " Watch "Casting " New topic
Author

Casting

Mark Henryson
Ranch Hand

Joined: Jul 11, 2005
Posts: 200


What is the difference between calling the method thru two different styles I have mentioned in the Code. One with BOLD and another with ITALIC. Both are giving the same result and why we are casting. What are the advantages of casting it?
satishkumar janakiraman
Ranch Hand

Joined: May 03, 2004
Posts: 334
Hi,


This line creates an instance of Parent but not an Object of Kid()
hence casting is required in this line
Now k1 is an object of Kid and calls the method method3();

in the line k is the object of Kid() and directly calls the method3()

i hope, it will clear ur doubts. If i am wrong, please post ur correct answer in this forum

Bye for now
sat
satishkumar janakiraman
Ranch Hand

Joined: May 03, 2004
Posts: 334
Hi small change in my previous posting




This line creates a Reference of Parent but not an Object of Kid()
hence casting is required in this line

bye for now
sat
satishkumar janakiraman
Ranch Hand

Joined: May 03, 2004
Posts: 334
Hi small change in my previous posting




This line creates a Reference to the Parent but not an Object of Parent.
hence casting is required in this line

bye for now
sat
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Casting