aspose file tools*
The moose likes Beginning Java and the fly likes virtual functions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "virtual functions" Watch "virtual functions" New topic
Author

virtual functions

P.Praveen Jesudhas
Greenhorn

Joined: Jul 23, 2006
Posts: 26
are virtual functions allowed in java
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Yes, Java supports polymorphism.


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Prathap Adusumilli
Greenhorn

Joined: Aug 23, 2006
Posts: 4
By default all the fucntions in java are virtual. In that if you are using a base call reference for an derived call object, the method in the derived class will be called (if its extended/implemented).
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

I guess I would say that all methods that can be overridden (i.e., non-static, non-private, and non-final) have the potential to be "virtual" in Java. But there is no "virtual" modifier, and the term is not commonly used in Java.
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
I think you could savely say that in Java all instance methods are virtual, all static methods aren't.


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: virtual functions