Question :What is meant by Virtual function in Java? Does Java supports Virtual
function? (CoreJava)
Answer :Java supports Virtual functions, all functions in Java are virtual by default.
Virtual functions or virtual methods are functions or methods that will be
redefined in derived classes.
Pure Virtual functions from C++ could be abstract functions without body.
Make your class abstract, define the pure virtual methods you want
subclasseses to provide implementation for
(using the abstract keyword in their definition) and you should be good.
public abstract class MyClass {
public void concreteInitThing() {
// your code here
}
public abstract void specificImplementation(); //Virtual method
}
public class ConcreteImplementationOfMyClass extends MyClass {
public void specificImplementation() {
// Your code here
}
}
www.interviewhelper.org is a hope for all the Job seekers. Users can find unlimited here. These range from technical to HR, from functional to behavioral. www.interviewhelper.org contains in the fields like Ajax,VB,Networking,Sharepoint,JEE,Perl,Javascript,Bioinformatics,Classic ASP,Unix,Linux,Accounting,Oracle DBA,Microprocessor,Bluetooth,jms,jme,.net framework,ABAP,ASP,ASP.net,Basic .net Framework,Interview Questions,C language,C++,database,Oracle,Java,PHP,LAMP,SAP etc.
Thursday, March 12, 2009
What is meant by Virtual function in Java? Does Java supports Virtual
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment