This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets 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: 688

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