aspose file tools*
The moose likes Beginning Java and the fly likes query 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 "query" Watch "query" New topic
Author

query

ajay Kumar Rana
Greenhorn

Joined: Feb 04, 2008
Posts: 2
Can we pass a reference of subclass to a method which has parameter of superclass type.
Kaydell Leavitt
Ranch Hand

Joined: Nov 18, 2006
Posts: 689

Welcome to the Java Ranch,

Can we pass a reference of subclass to a method which has parameter of superclass type.


Yes. In fact it is generally good to use a more abstract class or even an interface which is more abstract as parameters because this makes your method more general.

Kaydell
 
Don't get me started about those stupid light bulbs.
 
subject: query